{"id":2549,"date":"2016-02-04T14:15:46","date_gmt":"2016-02-04T05:15:46","guid":{"rendered":"http:\/\/blog.rutake.com\/techmemo\/?p=2549"},"modified":"2016-02-04T14:15:46","modified_gmt":"2016-02-04T05:15:46","slug":"python-boto3-aws%e3%81%aecredential%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b","status":"publish","type":"post","link":"https:\/\/blog.rutake.com\/techmemo\/2016\/02\/04\/python-boto3-aws%e3%81%aecredential%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b\/","title":{"rendered":"python boto3 aws\u306ecredential\u3092\u5207\u308a\u66ff\u3048\u308b"},"content":{"rendered":"<p>aws cli\u306eprofile\u3092\u8907\u6570\u6301\u3063\u3066\u3044\u308b\u3068\u304d\u306b\u3001boto3\u3067\u306f\u3069\u306e\u3088\u3046\u306b\u6307\u5b9a\u3059\u308b\u306e\u304b\uff1f<\/p>\n<p>\u74b0\u5883\u5909\u6570\u306b\u5165\u308c\u308b\u306e\u306f\u8a2d\u5b9a\u304c\u3070\u3089\u3070\u3089\u306b\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3001\u3067\u304d\u308c\u3070.aws\/credentials\u306b\u3042\u308b\u60c5\u5831\u3092\u5229\u7528\u3057\u305f\u3044\u3002<\/p>\n<p>\u305d\u3093\u306a\u6642\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3059\u308b\u3068\u5f15\u6570\u3067\u6307\u5b9a\u3057\u305fprofile\u3092\u5229\u7528\u3067\u304d\u308b\u3002<\/p>\n<p>[python]<br \/>\nimport sys<br \/>\nimport boto3<\/p>\n<p># get profile from argument<br \/>\nargv = sys.argv<br \/>\nargc = len(argv)<\/p>\n<p>if (argc == 0):<br \/>\n        print &#8220;use dafult profile&#8221;<br \/>\n        profile = &#8220;default&#8221;<br \/>\nelse:<br \/>\n        print &#8220;use %s&#8221; % argv[1]<br \/>\n        profile = argv[1]<\/p>\n<p>session = boto3.session.Session(profile_name=profile)<br \/>\n[\/python]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>aws cli\u306eprofile\u3092\u8907\u6570\u6301\u3063\u3066\u3044\u308b\u3068\u304d\u306b\u3001boto3\u3067\u306f\u3069\u306e\u3088\u3046\u306b\u6307 &hellip; <a href=\"https:\/\/blog.rutake.com\/techmemo\/2016\/02\/04\/python-boto3-aws%e3%81%aecredential%e3%82%92%e5%88%87%e3%82%8a%e6%9b%bf%e3%81%88%e3%82%8b\/\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[500,501],"_links":{"self":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2549"}],"collection":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/comments?post=2549"}],"version-history":[{"count":1,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2549\/revisions"}],"predecessor-version":[{"id":2550,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/posts\/2549\/revisions\/2550"}],"wp:attachment":[{"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/media?parent=2549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/categories?post=2549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.rutake.com\/techmemo\/wp-json\/wp\/v2\/tags?post=2549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}