{"action":"created","comment":{"url":"https://api.github.com/repos/aws/aws-sdk-go/pulls/comments/56251068","id":56251068,"diff_hunk":"@@ -111,6 +111,16 @@ func (m *EC2RoleProvider) Retrieve() (credentials.Value, error) {\n \t}, nil\n }\n \n+// GetIdentityDocument retrieves an identity document describing an instance\n+func (m *EC2RoleProvider) GetIdentityDocument() (*EC2InstanceIdentityDocument, error) {","path":"aws/credentials/ec2rolecreds/ec2_role_provider.go","position":5,"original_position":5,"commit_id":"a25640ff24a8dc3505487d2ac53c2fb999c13f26","original_commit_id":"a25640ff24a8dc3505487d2ac53c2fb999c13f26","user":{"login":"radeksimko","id":287584,"avatar_url":"https://avatars.githubusercontent.com/u/287584?v=3","gravatar_id":"","url":"https://api.github.com/users/radeksimko","html_url":"https://github.com/radeksimko","followers_url":"https://api.github.com/users/radeksimko/followers","following_url":"https://api.github.com/users/radeksimko/following{/other_user}","gists_url":"https://api.github.com/users/radeksimko/gists{/gist_id}","starred_url":"https://api.github.com/users/radeksimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radeksimko/subscriptions","organizations_url":"https://api.github.com/users/radeksimko/orgs","repos_url":"https://api.github.com/users/radeksimko/repos","events_url":"https://api.github.com/users/radeksimko/events{/privacy}","received_events_url":"https://api.github.com/users/radeksimko/received_events","type":"User","site_admin":false},"body":"I'm tempted to agree, I just need to find out how does the interface change for the user of the SDK and how more/less complicated it will be... I think it should be ok, just one extra `import`... I guess.","created_at":"2016-03-15T22:18:17Z","updated_at":"2016-03-15T22:18:17Z","html_url":"https://github.com/aws/aws-sdk-go/pull/590#discussion_r56251068","pull_request_url":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590","_links":{"self":{"href":"https://api.github.com/repos/aws/aws-sdk-go/pulls/comments/56251068"},"html":{"href":"https://github.com/aws/aws-sdk-go/pull/590#discussion_r56251068"},"pull_request":{"href":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590"}}},"pull_request":{"url":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590","id":62677570,"html_url":"https://github.com/aws/aws-sdk-go/pull/590","diff_url":"https://github.com/aws/aws-sdk-go/pull/590.diff","patch_url":"https://github.com/aws/aws-sdk-go/pull/590.patch","issue_url":"https://api.github.com/repos/aws/aws-sdk-go/issues/590","number":590,"state":"open","locked":false,"title":"ec2rolecreds: Add method for getting instance identity doc","user":{"login":"radeksimko","id":287584,"avatar_url":"https://avatars.githubusercontent.com/u/287584?v=3","gravatar_id":"","url":"https://api.github.com/users/radeksimko","html_url":"https://github.com/radeksimko","followers_url":"https://api.github.com/users/radeksimko/followers","following_url":"https://api.github.com/users/radeksimko/following{/other_user}","gists_url":"https://api.github.com/users/radeksimko/gists{/gist_id}","starred_url":"https://api.github.com/users/radeksimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radeksimko/subscriptions","organizations_url":"https://api.github.com/users/radeksimko/orgs","repos_url":"https://api.github.com/users/radeksimko/repos","events_url":"https://api.github.com/users/radeksimko/events{/privacy}","received_events_url":"https://api.github.com/users/radeksimko/received_events","type":"User","site_admin":false},"body":"This is an implementation of a very basic check for \"authenticity\" of an EC2 metadata API as discussed in https://github.com/aws/aws-sdk-go/issues/543\r\n\r\nThis is how I'd expect people to use it:\r\n\r\n```go\r\nfunc getCreds(key, secret, token, profile, credsfile string) *awsCredentials.Credentials {\r\n\tproviders := []awsCredentials.Provider{\r\n\t\t&awsCredentials.StaticProvider{Value: awsCredentials.Value{\r\n\t\t\tAccessKeyID:     key,\r\n\t\t\tSecretAccessKey: secret,\r\n\t\t\tSessionToken:    token,\r\n\t\t}},\r\n\t\t&awsCredentials.EnvProvider{},\r\n\t\t&awsCredentials.SharedCredentialsProvider{\r\n\t\t\tFilename: credsfile,\r\n\t\t\tProfile:  profile,\r\n\t\t},\r\n\t}\r\n\r\n\tcfg := &aws.Config{}\r\n\tendpoint := os.Getenv(\"AWS_METADATA_ENDPOINT\")\r\n\tif endpoint != \"\" {\r\n\t\tcfg.Endpoint = aws.String(getMetadataEndpoint())\r\n\t}\r\n\t\r\n\tec2Provider := &ec2rolecreds.EC2RoleProvider{\r\n\t\tClient: ec2metadata.New(session.New(cfg)),\r\n\t}\r\n\r\n\t// Unless custom endpoint was given, verify it\r\n\tif endpoint == \"\" {\r\n\t\t_, err := ec2Provider.GetIdentityDocument()\r\n\t\tif err == nil {\r\n\t\t\tproviders = append(providers, ec2Provider)\r\n\t\t} else {\r\n\t\t\tlog.Printf(\"Failed to get instance identity document: %s\", err)\r\n\t\t}\r\n\t}\r\n\r\n\treturn awsCredentials.NewChainCredentials(providers)\r\n}\r\n```\r\n\r\nIs there any standardised name for the ENV variable (`AWS_METADATA_ENDPOINT`)?\r\n\r\nThe PKCS7 signature verification can be a next iteration in a separate PR - I tried to keep this simple for the beginning.","created_at":"2016-03-13T17:49:42Z","updated_at":"2016-03-15T22:18:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c420e1502e0799213a77c6be946c0ce1a36de1fe","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590/commits","review_comments_url":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590/comments","review_comment_url":"https://api.github.com/repos/aws/aws-sdk-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aws/aws-sdk-go/issues/590/comments","statuses_url":"https://api.github.com/repos/aws/aws-sdk-go/statuses/a25640ff24a8dc3505487d2ac53c2fb999c13f26","head":{"label":"radeksimko:f-ec2-metadata-verification","ref":"f-ec2-metadata-verification","sha":"a25640ff24a8dc3505487d2ac53c2fb999c13f26","user":{"login":"radeksimko","id":287584,"avatar_url":"https://avatars.githubusercontent.com/u/287584?v=3","gravatar_id":"","url":"https://api.github.com/users/radeksimko","html_url":"https://github.com/radeksimko","followers_url":"https://api.github.com/users/radeksimko/followers","following_url":"https://api.github.com/users/radeksimko/following{/other_user}","gists_url":"https://api.github.com/users/radeksimko/gists{/gist_id}","starred_url":"https://api.github.com/users/radeksimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radeksimko/subscriptions","organizations_url":"https://api.github.com/users/radeksimko/orgs","repos_url":"https://api.github.com/users/radeksimko/repos","events_url":"https://api.github.com/users/radeksimko/events{/privacy}","received_events_url":"https://api.github.com/users/radeksimko/received_events","type":"User","site_admin":false},"repo":{"id":39954456,"name":"aws-sdk-go","full_name":"radeksimko/aws-sdk-go","owner":{"login":"radeksimko","id":287584,"avatar_url":"https://avatars.githubusercontent.com/u/287584?v=3","gravatar_id":"","url":"https://api.github.com/users/radeksimko","html_url":"https://github.com/radeksimko","followers_url":"https://api.github.com/users/radeksimko/followers","following_url":"https://api.github.com/users/radeksimko/following{/other_user}","gists_url":"https://api.github.com/users/radeksimko/gists{/gist_id}","starred_url":"https://api.github.com/users/radeksimko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/radeksimko/subscriptions","organizations_url":"https://api.github.com/users/radeksimko/orgs","repos_url":"https://api.github.com/users/radeksimko/repos","events_url":"https://api.github.com/users/radeksimko/events{/privacy}","received_events_url":"https://api.github.com/users/radeksimko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/radeksimko/aws-sdk-go","description":"AWS SDK for the Go programming language.","fork":true,"url":"https://api.github.com/repos/radeksimko/aws-sdk-go","forks_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/forks","keys_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/teams","hooks_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/hooks","issue_events_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/issues/events{/number}","events_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/events","assignees_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/assignees{/user}","branches_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/branches{/branch}","tags_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/tags","blobs_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/statuses/{sha}","languages_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/languages","stargazers_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/stargazers","contributors_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/contributors","subscribers_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/subscribers","subscription_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/subscription","commits_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/contents/{+path}","compare_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/merges","archive_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/downloads","issues_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/issues{/number}","pulls_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/pulls{/number}","milestones_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/milestones{/number}","notifications_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/labels{/name}","releases_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/releases{/id}","deployments_url":"https://api.github.com/repos/radeksimko/aws-sdk-go/deployments","created_at":"2015-07-30T14:20:35Z","updated_at":"2016-01-16T23:32:32Z","pushed_at":"2016-03-14T18:05:42Z","git_url":"git://github.com/radeksimko/aws-sdk-go.git","ssh_url":"git@github.com:radeksimko/aws-sdk-go.git","clone_url":"https://github.com/radeksimko/aws-sdk-go.git","svn_url":"https://github.com/radeksimko/aws-sdk-go","homepage":"http://aws.amazon.com/sdk-for-go/","size":20564,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"aws:master","ref":"master","sha":"4151ef572710e04d25d9385114b33847ba6a923a","user":{"login":"aws","id":2232217,"avatar_url":"https://avatars.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"repo":{"id":27576132,"name":"aws-sdk-go","full_name":"aws/aws-sdk-go","owner":{"login":"aws","id":2232217,"avatar_url":"https://avatars.githubusercontent.com/u/2232217?v=3","gravatar_id":"","url":"https://api.github.com/users/aws","html_url":"https://github.com/aws","followers_url":"https://api.github.com/users/aws/followers","following_url":"https://api.github.com/users/aws/following{/other_user}","gists_url":"https://api.github.com/users/aws/gists{/gist_id}","starred_url":"https://api.github.com/users/aws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aws/subscriptions","organizations_url":"https://api.github.com/users/aws/orgs","repos_url":"https://api.github.com/users/aws/repos","events_url":"https://api.github.com/users/aws/events{/privacy}","received_events_url":"https://api.github.com/users/aws/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aws/aws-sdk-go","description":"AWS SDK for the Go programming language.","fork":false,"url":"https://api.github.com/repos/aws/aws-sdk-go","forks_url":"https://api.github.com/repos/aws/aws-sdk-go/forks","keys_url":"https://api.github.com/repos/aws/aws-sdk-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aws/aws-sdk-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aws/aws-sdk-go/teams","hooks_url":"https://api.github.com/repos/aws/aws-sdk-go/hooks","issue_events_url":"https://api.github.com/repos/aws/aws-sdk-go/issues/events{/number}","events_url":"https://api.github.com/repos/aws/aws-sdk-go/events","assignees_url":"https://api.github.com/repos/aws/aws-sdk-go/assignees{/user}","branches_url":"https://api.github.com/repos/aws/aws-sdk-go/branches{/branch}","tags_url":"https://api.github.com/repos/aws/aws-sdk-go/tags","blobs_url":"https://api.github.com/repos/aws/aws-sdk-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aws/aws-sdk-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aws/aws-sdk-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/aws/aws-sdk-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aws/aws-sdk-go/statuses/{sha}","languages_url":"https://api.github.com/repos/aws/aws-sdk-go/languages","stargazers_url":"https://api.github.com/repos/aws/aws-sdk-go/stargazers","contributors_url":"https://api.github.com/repos/aws/aws-sdk-go/contributors","subscribers_url":"https://api.github.com/repos/aws/aws-sdk-go/subscribers","subscription_url":"https://api.github.com/repos/aws/aws-sdk-go/subscription","commits_url":"https://api.github.com/repos/aws/aws-sdk-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/aws/aws-sdk-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/aws/aws-sdk-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/aws/aws-sdk-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/aws/aws-sdk-go/contents/{+path}","compare_url":"https://api.github.com/repos/aws/aws-sdk-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aws/aws-sdk-go/merges","archive_url":"https://api.github.com/repos/aws/aws-sdk-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aws/aws-sdk-go/downloads","issues_url":"https://api.github.com/repos/aws/aws-sdk-go/issues{/number}","pulls_url":"https://api.github.com/repos/aws/aws-sdk-go/pulls{/number}","milestones_url":"https://api.github.com/repos/aws/aws-sdk-go/milestones{/number}","notifications_url":"https://api.github.com/repos/aws/aws-sdk-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aws/aws-sdk-go/labels{/name}","releases_url":"https://api.github.com/repos/aws/aws-sdk-go/releases{/id}","deployments_url":"https://api.github.com/repos/aws/aws-sdk-go/deployments","created_at":"2014-12-05T05:29:41Z","updated_at":"2016-03-15T17:38:24Z","pushed_at":"2016-03-15T22:09:03Z","git_url":"git://github.com/aws/aws-sdk-go.git","ssh_url":"git@github.com:aws/aws-sdk-go.git","clone_url":"https://github.com/aws/aws-sdk-go.git","svn_url":"https://github.com/aws/aws-sdk-go","homepage":"http://aws.amazon.com/sdk-for-go/","size":22200,"stargazers_count":2387,"watchers_count":2387,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":357,"mirror_url":null,"open_issues_count":42,"forks":357,"open_issues":42,"watchers":2387,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590"},"html":{"href":"https://github.com/aws/aws-sdk-go/pull/590"},"issue":{"href":"https://api.github.com/repos/aws/aws-sdk-go/issues/590"},"comments":{"href":"https://api.github.com/repos/aws/aws-sdk-go/issues/590/comments"},"review_comments":{"href":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590/comments"},"review_comment":{"href":"https://api.github.com/repos/aws/aws-sdk-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aws/aws-sdk-go/pulls/590/commits"},"statuses":{"href":"https://api.github.com/repos/aws/aws-sdk-go/statuses/a25640ff24a8dc3505487d2ac53c2fb999c13f26"}}}}