{"action":"created","comment":{"url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/comments/49098758","id":49098758,"diff_hunk":"@@ -13,27 +12,45 @@ public class AwsHttpConnection : HttpConnection\n     {\n         readonly string _accessKey;\n         readonly string _secretKey;\n+        readonly string _token;\n         readonly string _region;\n \n         /// <summary>\n-        /// Initializes a new instance of the AwsHttpConnection class.\n+        /// Initializes a new instance of the AwsHttpConnection class with the specified AccessKey, SecretKey and Token.\n         /// </summary>\n         /// <param name=\"settings\">The NEST/Elasticsearch.Net settings.</param>\n         /// <param name=\"awsSettings\">AWS specific settings required for signing requests.</param>\n         public AwsHttpConnection(IConnectionConfigurationValues settings, AwsSettings awsSettings) : base(settings)\n         {\n             if (awsSettings == null) throw new ArgumentNullException(\"awsSettings\");\n+            if (string.IsNullOrWhiteSpace(awsSettings.AccessKey)) throw new ArgumentException(\"awsSettings.AccessKey is invalid.\", \"awsSettings\");\n             if (string.IsNullOrWhiteSpace(awsSettings.SecretKey)) throw new ArgumentException(\"awsSettings.SecretKey is invalid.\", \"awsSettings\");\n             if (string.IsNullOrWhiteSpace(awsSettings.Region)) throw new ArgumentException(\"awsSettings.Region is invalid.\", \"awsSettings\");\n             _accessKey = awsSettings.AccessKey;\n             _secretKey = awsSettings.SecretKey;\n+            _token = awsSettings.Token;\n             _region = awsSettings.Region.ToLowerInvariant();\n         }\n \n+        /// <summary>\n+        /// Initializes a new instance of the AwsHttpConnection class with info from the Instance Profile service\n+        /// </summary>\n+        /// <param name=\"settings\">The NEST/Elasticsearch.Net settings.</param>\n+        public AwsHttpConnection(IConnectionConfigurationValues settings, string region) : base(settings)\n+        {\n+            var credentials = InstanceProfileService.GetCredentials();","path":"src/Elasticsearch.Net.Aws/Elasticsearch.Net.Aws/AwsHttpConnection.cs","position":37,"original_position":37,"commit_id":"a00fc8bd886cfae89a0c8f8d72c535c2555d216e","original_commit_id":"a00fc8bd886cfae89a0c8f8d72c535c2555d216e","user":{"login":"bcuff","id":504266,"avatar_url":"https://avatars.githubusercontent.com/u/504266?v=3","gravatar_id":"","url":"https://api.github.com/users/bcuff","html_url":"https://github.com/bcuff","followers_url":"https://api.github.com/users/bcuff/followers","following_url":"https://api.github.com/users/bcuff/following{/other_user}","gists_url":"https://api.github.com/users/bcuff/gists{/gist_id}","starred_url":"https://api.github.com/users/bcuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcuff/subscriptions","organizations_url":"https://api.github.com/users/bcuff/orgs","repos_url":"https://api.github.com/users/bcuff/repos","events_url":"https://api.github.com/users/bcuff/events{/privacy}","received_events_url":"https://api.github.com/users/bcuff/received_events","type":"User","site_admin":false},"body":"If you need to periodically refresh the credentials you might want to call `GetCredentials()` in `SignRequest`. In many cases users will likely create a single client for the life-time of the application. In that situation you might get stuck with stale credentials.","created_at":"2016-01-07T17:18:53Z","updated_at":"2016-01-07T17:18:53Z","html_url":"https://github.com/bcuff/elasticsearch-net-aws/pull/3#discussion_r49098758","pull_request_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/comments/49098758"},"html":{"href":"https://github.com/bcuff/elasticsearch-net-aws/pull/3#discussion_r49098758"},"pull_request":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3","id":55302152,"html_url":"https://github.com/bcuff/elasticsearch-net-aws/pull/3","diff_url":"https://github.com/bcuff/elasticsearch-net-aws/pull/3.diff","patch_url":"https://github.com/bcuff/elasticsearch-net-aws/pull/3.patch","issue_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/issues/3","number":3,"state":"open","locked":false,"title":"Added support for instance profile credentials","user":{"login":"david-poirier-csn","id":7286281,"avatar_url":"https://avatars.githubusercontent.com/u/7286281?v=3","gravatar_id":"","url":"https://api.github.com/users/david-poirier-csn","html_url":"https://github.com/david-poirier-csn","followers_url":"https://api.github.com/users/david-poirier-csn/followers","following_url":"https://api.github.com/users/david-poirier-csn/following{/other_user}","gists_url":"https://api.github.com/users/david-poirier-csn/gists{/gist_id}","starred_url":"https://api.github.com/users/david-poirier-csn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-poirier-csn/subscriptions","organizations_url":"https://api.github.com/users/david-poirier-csn/orgs","repos_url":"https://api.github.com/users/david-poirier-csn/repos","events_url":"https://api.github.com/users/david-poirier-csn/events{/privacy}","received_events_url":"https://api.github.com/users/david-poirier-csn/received_events","type":"User","site_admin":false},"body":"Some organizations (like mine!) do not allow devs to use Access Keys, so I've added support for Instance Profile Credentials. \r\n\r\nThe AWS SDK supports these, so I had a look at how they do it - basically they call a special URL at runtime to get a temporary Access Key, Secret Key and Token, and proceed as normal from there.\r\n\r\nThe key does expire eventually, so there is checking to ensure that a \"fresh\" set of credentials is always available.","created_at":"2016-01-07T05:46:04Z","updated_at":"2016-01-07T17:18:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"15507247e96e4e802b87ba8a5aca479aa1c9fe8c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3/commits","review_comments_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3/comments","review_comment_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/issues/3/comments","statuses_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/statuses/a00fc8bd886cfae89a0c8f8d72c535c2555d216e","head":{"label":"david-poirier-csn:master","ref":"master","sha":"a00fc8bd886cfae89a0c8f8d72c535c2555d216e","user":{"login":"david-poirier-csn","id":7286281,"avatar_url":"https://avatars.githubusercontent.com/u/7286281?v=3","gravatar_id":"","url":"https://api.github.com/users/david-poirier-csn","html_url":"https://github.com/david-poirier-csn","followers_url":"https://api.github.com/users/david-poirier-csn/followers","following_url":"https://api.github.com/users/david-poirier-csn/following{/other_user}","gists_url":"https://api.github.com/users/david-poirier-csn/gists{/gist_id}","starred_url":"https://api.github.com/users/david-poirier-csn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-poirier-csn/subscriptions","organizations_url":"https://api.github.com/users/david-poirier-csn/orgs","repos_url":"https://api.github.com/users/david-poirier-csn/repos","events_url":"https://api.github.com/users/david-poirier-csn/events{/privacy}","received_events_url":"https://api.github.com/users/david-poirier-csn/received_events","type":"User","site_admin":false},"repo":{"id":48349325,"name":"elasticsearch-net-aws","full_name":"david-poirier-csn/elasticsearch-net-aws","owner":{"login":"david-poirier-csn","id":7286281,"avatar_url":"https://avatars.githubusercontent.com/u/7286281?v=3","gravatar_id":"","url":"https://api.github.com/users/david-poirier-csn","html_url":"https://github.com/david-poirier-csn","followers_url":"https://api.github.com/users/david-poirier-csn/followers","following_url":"https://api.github.com/users/david-poirier-csn/following{/other_user}","gists_url":"https://api.github.com/users/david-poirier-csn/gists{/gist_id}","starred_url":"https://api.github.com/users/david-poirier-csn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-poirier-csn/subscriptions","organizations_url":"https://api.github.com/users/david-poirier-csn/orgs","repos_url":"https://api.github.com/users/david-poirier-csn/repos","events_url":"https://api.github.com/users/david-poirier-csn/events{/privacy}","received_events_url":"https://api.github.com/users/david-poirier-csn/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/david-poirier-csn/elasticsearch-net-aws","description":"Add-on to elasticsearch-net for using AWS's elasticsearch service.","fork":true,"url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws","forks_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/forks","keys_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/keys{/key_id}","collaborators_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/teams","hooks_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/hooks","issue_events_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/issues/events{/number}","events_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/events","assignees_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/assignees{/user}","branches_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/branches{/branch}","tags_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/tags","blobs_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/git/refs{/sha}","trees_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/git/trees{/sha}","statuses_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/statuses/{sha}","languages_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/languages","stargazers_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/stargazers","contributors_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/contributors","subscribers_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/subscribers","subscription_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/subscription","commits_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/commits{/sha}","git_commits_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/git/commits{/sha}","comments_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/comments{/number}","issue_comment_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/issues/comments{/number}","contents_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/contents/{+path}","compare_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/compare/{base}...{head}","merges_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/merges","archive_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/downloads","issues_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/issues{/number}","pulls_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/pulls{/number}","milestones_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/milestones{/number}","notifications_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/labels{/name}","releases_url":"https://api.github.com/repos/david-poirier-csn/elasticsearch-net-aws/releases{/id}","created_at":"2015-12-21T03:48:21Z","updated_at":"2015-12-21T03:48:22Z","pushed_at":"2016-01-07T05:41:23Z","git_url":"git://github.com/david-poirier-csn/elasticsearch-net-aws.git","ssh_url":"git@github.com:david-poirier-csn/elasticsearch-net-aws.git","clone_url":"https://github.com/david-poirier-csn/elasticsearch-net-aws.git","svn_url":"https://github.com/david-poirier-csn/elasticsearch-net-aws","homepage":null,"size":31,"stargazers_count":0,"watchers_count":0,"language":"C#","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":"bcuff:master","ref":"master","sha":"8ca1564b25687523535518fd95568b8e0c79b996","user":{"login":"bcuff","id":504266,"avatar_url":"https://avatars.githubusercontent.com/u/504266?v=3","gravatar_id":"","url":"https://api.github.com/users/bcuff","html_url":"https://github.com/bcuff","followers_url":"https://api.github.com/users/bcuff/followers","following_url":"https://api.github.com/users/bcuff/following{/other_user}","gists_url":"https://api.github.com/users/bcuff/gists{/gist_id}","starred_url":"https://api.github.com/users/bcuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcuff/subscriptions","organizations_url":"https://api.github.com/users/bcuff/orgs","repos_url":"https://api.github.com/users/bcuff/repos","events_url":"https://api.github.com/users/bcuff/events{/privacy}","received_events_url":"https://api.github.com/users/bcuff/received_events","type":"User","site_admin":false},"repo":{"id":44559004,"name":"elasticsearch-net-aws","full_name":"bcuff/elasticsearch-net-aws","owner":{"login":"bcuff","id":504266,"avatar_url":"https://avatars.githubusercontent.com/u/504266?v=3","gravatar_id":"","url":"https://api.github.com/users/bcuff","html_url":"https://github.com/bcuff","followers_url":"https://api.github.com/users/bcuff/followers","following_url":"https://api.github.com/users/bcuff/following{/other_user}","gists_url":"https://api.github.com/users/bcuff/gists{/gist_id}","starred_url":"https://api.github.com/users/bcuff/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bcuff/subscriptions","organizations_url":"https://api.github.com/users/bcuff/orgs","repos_url":"https://api.github.com/users/bcuff/repos","events_url":"https://api.github.com/users/bcuff/events{/privacy}","received_events_url":"https://api.github.com/users/bcuff/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bcuff/elasticsearch-net-aws","description":"Add-on to elasticsearch-net for using AWS's elasticsearch service.","fork":false,"url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws","forks_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/forks","keys_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/teams","hooks_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/hooks","issue_events_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/issues/events{/number}","events_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/events","assignees_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/assignees{/user}","branches_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/branches{/branch}","tags_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/tags","blobs_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/git/refs{/sha}","trees_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/statuses/{sha}","languages_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/languages","stargazers_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/stargazers","contributors_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/contributors","subscribers_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/subscribers","subscription_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/subscription","commits_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/commits{/sha}","git_commits_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/git/commits{/sha}","comments_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/comments{/number}","issue_comment_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/issues/comments{/number}","contents_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/contents/{+path}","compare_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/merges","archive_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/downloads","issues_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/issues{/number}","pulls_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls{/number}","milestones_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/milestones{/number}","notifications_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/labels{/name}","releases_url":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/releases{/id}","created_at":"2015-10-19T19:38:12Z","updated_at":"2015-11-03T19:15:42Z","pushed_at":"2016-01-07T05:46:04Z","git_url":"git://github.com/bcuff/elasticsearch-net-aws.git","ssh_url":"git@github.com:bcuff/elasticsearch-net-aws.git","clone_url":"https://github.com/bcuff/elasticsearch-net-aws.git","svn_url":"https://github.com/bcuff/elasticsearch-net-aws","homepage":null,"size":26,"stargazers_count":2,"watchers_count":2,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":1,"forks":3,"open_issues":1,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3"},"html":{"href":"https://github.com/bcuff/elasticsearch-net-aws/pull/3"},"issue":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/issues/3"},"comments":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/bcuff/elasticsearch-net-aws/statuses/a00fc8bd886cfae89a0c8f8d72c535c2555d216e"}}}}