{"action":"created","comment":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/38531558","id":38531558,"diff_hunk":"@@ -1281,12 +1281,38 @@ func (self *AWSCloud) TCPLoadBalancerExists(name, region string) (bool, error) {\n \treturn false, nil\n }\n \n+// Retrieves instance's vpc id from metadata\n+func (self *AWSCloud) findVPCID() (string, error) {\n+\n+\tmetadata := self.awsServices.Metadata()\n+\tmacsBytes, err := metadata.GetMetaData(\"network/interfaces/macs/\")\n+\tif err != nil {\n+\t\treturn \"\", fmt.Errorf(\"Could not list interfaces of the instance\", err)\n+\t}\n+\n+\t// loop over interfaces, first vpc id returned wins\n+\tfor _, macPath := range strings.Split(string(macsBytes), \"\\n\") {\n+\n+\t\tif len(macPath) == 0 {\n+\t\t\tcontinue\n+\t\t}\n+\t\turl := fmt.Sprintf(\"network/interfaces/macs/%svpc-id\", macPath)\n+\t\tvpcIDBytes, err := metadata.GetMetaData(url)\n+\t\tif err != nil {\n+\t\t\tcontinue\n+\t\t}\n+\t\treturn string(vpcIDBytes), nil\n+\t}\n+\treturn \"\", fmt.Errorf(\"Could not find VPC id in instance metadata\")\n+}\n+\n // Find the kubernetes VPC\n func (self *AWSCloud) findVPC() (*ec2.VPC, error) {\n \trequest := &ec2.DescribeVPCsInput{}\n \n-\tname := \"kubernetes-vpc\"\n-\tfilters := []*ec2.Filter{newEc2Filter(\"tag:Name\", name)}\n+\t// find by vpcID from metadata\n+\tvpcID, err := self.findVPCID()","path":"pkg/cloudprovider/providers/aws/aws.go","position":36,"original_position":36,"commit_id":"982fdd80e1f00382a784c4aa7a74769402bbc581","original_commit_id":"982fdd80e1f00382a784c4aa7a74769402bbc581","user":{"login":"justinsb","id":100893,"avatar_url":"https://avatars.githubusercontent.com/u/100893?v=3","gravatar_id":"","url":"https://api.github.com/users/justinsb","html_url":"https://github.com/justinsb","followers_url":"https://api.github.com/users/justinsb/followers","following_url":"https://api.github.com/users/justinsb/following{/other_user}","gists_url":"https://api.github.com/users/justinsb/gists{/gist_id}","starred_url":"https://api.github.com/users/justinsb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinsb/subscriptions","organizations_url":"https://api.github.com/users/justinsb/orgs","repos_url":"https://api.github.com/users/justinsb/repos","events_url":"https://api.github.com/users/justinsb/events{/privacy}","received_events_url":"https://api.github.com/users/justinsb/received_events","type":"User","site_admin":false},"body":"I think you do need to check err here.","created_at":"2015-09-02T13:36:03Z","updated_at":"2015-09-02T13:36:03Z","html_url":"https://github.com/kubernetes/kubernetes/pull/13467#discussion_r38531558","pull_request_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467","_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments/38531558"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/13467#discussion_r38531558"},"pull_request":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467"}}},"pull_request":{"url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467","id":43929863,"html_url":"https://github.com/kubernetes/kubernetes/pull/13467","diff_url":"https://github.com/kubernetes/kubernetes/pull/13467.diff","patch_url":"https://github.com/kubernetes/kubernetes/pull/13467.patch","issue_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/13467","number":13467,"state":"open","locked":false,"title":"Enhanced detection of VPC for cloudprovider AWS","user":{"login":"simonswine","id":223048,"avatar_url":"https://avatars.githubusercontent.com/u/223048?v=3","gravatar_id":"","url":"https://api.github.com/users/simonswine","html_url":"https://github.com/simonswine","followers_url":"https://api.github.com/users/simonswine/followers","following_url":"https://api.github.com/users/simonswine/following{/other_user}","gists_url":"https://api.github.com/users/simonswine/gists{/gist_id}","starred_url":"https://api.github.com/users/simonswine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonswine/subscriptions","organizations_url":"https://api.github.com/users/simonswine/orgs","repos_url":"https://api.github.com/users/simonswine/repos","events_url":"https://api.github.com/users/simonswine/events{/privacy}","received_events_url":"https://api.github.com/users/simonswine/received_events","type":"User","site_admin":false},"body":"Hi everybody,\r\n\r\ntoday I ran into trouble, when I wanted to use the cloud provider plugin for AWS with a custom VPC name. A look into the code has revealed hardcoding of the VPC name. This PR queries AWS' metadata service for the right VPC id. I think that is much more cleaner...\r\n\r\nPlease review my PR and give me hints what I am doing wrong.\r\n\r\nCheers,\r\nsimonswine","created_at":"2015-09-01T21:36:50Z","updated_at":"2015-09-02T13:36:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"632557185cd567f46500aaa58252a56d57349625","assignee":{"login":"bgrant0607","id":7725777,"avatar_url":"https://avatars.githubusercontent.com/u/7725777?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrant0607","html_url":"https://github.com/bgrant0607","followers_url":"https://api.github.com/users/bgrant0607/followers","following_url":"https://api.github.com/users/bgrant0607/following{/other_user}","gists_url":"https://api.github.com/users/bgrant0607/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrant0607/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrant0607/subscriptions","organizations_url":"https://api.github.com/users/bgrant0607/orgs","repos_url":"https://api.github.com/users/bgrant0607/repos","events_url":"https://api.github.com/users/bgrant0607/events{/privacy}","received_events_url":"https://api.github.com/users/bgrant0607/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467/commits","review_comments_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467/comments","review_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/13467/comments","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/982fdd80e1f00382a784c4aa7a74769402bbc581","head":{"label":"simonswine:feature_enhanced_vpc_detection","ref":"feature_enhanced_vpc_detection","sha":"982fdd80e1f00382a784c4aa7a74769402bbc581","user":{"login":"simonswine","id":223048,"avatar_url":"https://avatars.githubusercontent.com/u/223048?v=3","gravatar_id":"","url":"https://api.github.com/users/simonswine","html_url":"https://github.com/simonswine","followers_url":"https://api.github.com/users/simonswine/followers","following_url":"https://api.github.com/users/simonswine/following{/other_user}","gists_url":"https://api.github.com/users/simonswine/gists{/gist_id}","starred_url":"https://api.github.com/users/simonswine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonswine/subscriptions","organizations_url":"https://api.github.com/users/simonswine/orgs","repos_url":"https://api.github.com/users/simonswine/repos","events_url":"https://api.github.com/users/simonswine/events{/privacy}","received_events_url":"https://api.github.com/users/simonswine/received_events","type":"User","site_admin":false},"repo":{"id":41757650,"name":"kubernetes","full_name":"simonswine/kubernetes","owner":{"login":"simonswine","id":223048,"avatar_url":"https://avatars.githubusercontent.com/u/223048?v=3","gravatar_id":"","url":"https://api.github.com/users/simonswine","html_url":"https://github.com/simonswine","followers_url":"https://api.github.com/users/simonswine/followers","following_url":"https://api.github.com/users/simonswine/following{/other_user}","gists_url":"https://api.github.com/users/simonswine/gists{/gist_id}","starred_url":"https://api.github.com/users/simonswine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonswine/subscriptions","organizations_url":"https://api.github.com/users/simonswine/orgs","repos_url":"https://api.github.com/users/simonswine/repos","events_url":"https://api.github.com/users/simonswine/events{/privacy}","received_events_url":"https://api.github.com/users/simonswine/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/simonswine/kubernetes","description":"Container Cluster Manager from Google","fork":true,"url":"https://api.github.com/repos/simonswine/kubernetes","forks_url":"https://api.github.com/repos/simonswine/kubernetes/forks","keys_url":"https://api.github.com/repos/simonswine/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simonswine/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simonswine/kubernetes/teams","hooks_url":"https://api.github.com/repos/simonswine/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/simonswine/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/simonswine/kubernetes/events","assignees_url":"https://api.github.com/repos/simonswine/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/simonswine/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/simonswine/kubernetes/tags","blobs_url":"https://api.github.com/repos/simonswine/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simonswine/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simonswine/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/simonswine/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simonswine/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/simonswine/kubernetes/languages","stargazers_url":"https://api.github.com/repos/simonswine/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/simonswine/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/simonswine/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/simonswine/kubernetes/subscription","commits_url":"https://api.github.com/repos/simonswine/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/simonswine/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/simonswine/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/simonswine/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/simonswine/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/simonswine/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simonswine/kubernetes/merges","archive_url":"https://api.github.com/repos/simonswine/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simonswine/kubernetes/downloads","issues_url":"https://api.github.com/repos/simonswine/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/simonswine/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/simonswine/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/simonswine/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simonswine/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/simonswine/kubernetes/releases{/id}","created_at":"2015-09-01T19:05:08Z","updated_at":"2015-09-01T19:05:14Z","pushed_at":"2015-09-02T09:53:12Z","git_url":"git://github.com/simonswine/kubernetes.git","ssh_url":"git@github.com:simonswine/kubernetes.git","clone_url":"https://github.com/simonswine/kubernetes.git","svn_url":"https://github.com/simonswine/kubernetes","homepage":"http://kubernetes.io","size":104630,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kubernetes:master","ref":"master","sha":"d23d083439d4b936ceaa82d562fc9880906412c4","user":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"repo":{"id":20580498,"name":"kubernetes","full_name":"kubernetes/kubernetes","owner":{"login":"kubernetes","id":13629408,"avatar_url":"https://avatars.githubusercontent.com/u/13629408?v=3","gravatar_id":"","url":"https://api.github.com/users/kubernetes","html_url":"https://github.com/kubernetes","followers_url":"https://api.github.com/users/kubernetes/followers","following_url":"https://api.github.com/users/kubernetes/following{/other_user}","gists_url":"https://api.github.com/users/kubernetes/gists{/gist_id}","starred_url":"https://api.github.com/users/kubernetes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kubernetes/subscriptions","organizations_url":"https://api.github.com/users/kubernetes/orgs","repos_url":"https://api.github.com/users/kubernetes/repos","events_url":"https://api.github.com/users/kubernetes/events{/privacy}","received_events_url":"https://api.github.com/users/kubernetes/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/kubernetes/kubernetes","description":"Container Cluster Manager from Google","fork":false,"url":"https://api.github.com/repos/kubernetes/kubernetes","forks_url":"https://api.github.com/repos/kubernetes/kubernetes/forks","keys_url":"https://api.github.com/repos/kubernetes/kubernetes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kubernetes/kubernetes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kubernetes/kubernetes/teams","hooks_url":"https://api.github.com/repos/kubernetes/kubernetes/hooks","issue_events_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/events{/number}","events_url":"https://api.github.com/repos/kubernetes/kubernetes/events","assignees_url":"https://api.github.com/repos/kubernetes/kubernetes/assignees{/user}","branches_url":"https://api.github.com/repos/kubernetes/kubernetes/branches{/branch}","tags_url":"https://api.github.com/repos/kubernetes/kubernetes/tags","blobs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kubernetes/kubernetes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kubernetes/kubernetes/git/refs{/sha}","trees_url":"https://api.github.com/repos/kubernetes/kubernetes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kubernetes/kubernetes/statuses/{sha}","languages_url":"https://api.github.com/repos/kubernetes/kubernetes/languages","stargazers_url":"https://api.github.com/repos/kubernetes/kubernetes/stargazers","contributors_url":"https://api.github.com/repos/kubernetes/kubernetes/contributors","subscribers_url":"https://api.github.com/repos/kubernetes/kubernetes/subscribers","subscription_url":"https://api.github.com/repos/kubernetes/kubernetes/subscription","commits_url":"https://api.github.com/repos/kubernetes/kubernetes/commits{/sha}","git_commits_url":"https://api.github.com/repos/kubernetes/kubernetes/git/commits{/sha}","comments_url":"https://api.github.com/repos/kubernetes/kubernetes/comments{/number}","issue_comment_url":"https://api.github.com/repos/kubernetes/kubernetes/issues/comments{/number}","contents_url":"https://api.github.com/repos/kubernetes/kubernetes/contents/{+path}","compare_url":"https://api.github.com/repos/kubernetes/kubernetes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kubernetes/kubernetes/merges","archive_url":"https://api.github.com/repos/kubernetes/kubernetes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kubernetes/kubernetes/downloads","issues_url":"https://api.github.com/repos/kubernetes/kubernetes/issues{/number}","pulls_url":"https://api.github.com/repos/kubernetes/kubernetes/pulls{/number}","milestones_url":"https://api.github.com/repos/kubernetes/kubernetes/milestones{/number}","notifications_url":"https://api.github.com/repos/kubernetes/kubernetes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kubernetes/kubernetes/labels{/name}","releases_url":"https://api.github.com/repos/kubernetes/kubernetes/releases{/id}","created_at":"2014-06-06T22:56:04Z","updated_at":"2015-09-02T13:18:38Z","pushed_at":"2015-09-02T13:27:50Z","git_url":"git://github.com/kubernetes/kubernetes.git","ssh_url":"git@github.com:kubernetes/kubernetes.git","clone_url":"https://github.com/kubernetes/kubernetes.git","svn_url":"https://github.com/kubernetes/kubernetes","homepage":"http://kubernetes.io","size":401819,"stargazers_count":10022,"watchers_count":10022,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":2441,"mirror_url":null,"open_issues_count":1706,"forks":2441,"open_issues":1706,"watchers":10022,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467"},"html":{"href":"https://github.com/kubernetes/kubernetes/pull/13467"},"issue":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/13467"},"comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/issues/13467/comments"},"review_comments":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467/comments"},"review_comment":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kubernetes/kubernetes/pulls/13467/commits"},"statuses":{"href":"https://api.github.com/repos/kubernetes/kubernetes/statuses/982fdd80e1f00382a784c4aa7a74769402bbc581"}}}}