{"id":682,"date":"2019-03-18T05:35:34","date_gmt":"2019-03-18T05:35:34","guid":{"rendered":"https:\/\/www.kolkataonweb.com\/code-bank\/?p=682"},"modified":"2019-03-12T10:57:56","modified_gmt":"2019-03-12T10:57:56","slug":"amazon-aws-sdk-passing-credentials","status":"publish","type":"post","link":"https:\/\/www.kolkataonweb.com\/code-bank\/miscellaneous\/amazon-aws-sdk-passing-credentials\/","title":{"rendered":"Amazon AWS SDK Passing Credentials"},"content":{"rendered":"<p>As per the the sample codes the AWS API access key and secret is to be stored in the a file called\u00a0<em>credentials\u00a0<\/em>under a folder named <em>.aws\u00a0<\/em><\/p>\n<p>The location of that <em>.aws <\/em>folder can be set in the code through this config statement<\/p>\n<pre class='wp-code-highlight prettyprint'>putenv('HOME=\/path\/that\/you\/want\/to\/set');<\/pre>\n<p>But I am more comfortable in passing the credentials through my code so that I can make things more flexible and need not worry about write permissions.<\/p>\n<p>To pass the credentials through code the first thing needed is to remove or not to use the config statement<\/p>\n<pre class='wp-code-highlight prettyprint'>'profile' =&gt; 'default'<\/pre>\n<p>The credentials can then be passed like below<\/p>\n<pre class='wp-code-highlight prettyprint'>$xxxxxxClient = new xxxxxxClient([\r\n   'version' =&gt; \"&lt;CLIENT VERSION&gt;\", \/* can be set to 'latest' *\/\r\n   'region' =&gt; \"&lt;REGION&gt;\",\r\n   'credentials' =&gt; array(\r\n     'key' =&gt; \"&lt;API USER&gt;\",\r\n     'secret' =&gt; \"&lt;API PASS&gt;\"\r\n    )\r\n]);<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As per the the sample codes the AWS API access key and secret is to be stored in the a file called\u00a0credentials\u00a0under a folder named .aws\u00a0 The location of that .aws folder can be set in the code through this config statement putenv(&#8216;HOME=\/path\/that\/you\/want\/to\/set&#8217;); But I am more comfortable in passing the credentials through my code&hellip; <a class=\"more-link\" href=\"https:\/\/www.kolkataonweb.com\/code-bank\/miscellaneous\/amazon-aws-sdk-passing-credentials\/\">Continue reading <span class=\"screen-reader-text\">Amazon AWS SDK Passing Credentials<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,3],"tags":[147,172,173],"class_list":["post-682","post","type-post","status-publish","format-standard","hentry","category-miscellaneous","category-php","tag-amazon-aws","tag-aws","tag-sdk","entry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/comments?post=682"}],"version-history":[{"count":1,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/682\/revisions"}],"predecessor-version":[{"id":684,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/posts\/682\/revisions\/684"}],"wp:attachment":[{"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/media?parent=682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/categories?post=682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kolkataonweb.com\/code-bank\/wp-json\/wp\/v2\/tags?post=682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}