{"id":3883,"date":"2025-10-28T17:44:08","date_gmt":"2025-10-28T09:44:08","guid":{"rendered":"https:\/\/aws-oncloudai.com\/?p=3883"},"modified":"2025-10-28T16:09:31","modified_gmt":"2025-10-28T08:09:31","slug":"manage-the-aws-cli-efficiently-using-aws-configure","status":"publish","type":"post","link":"https:\/\/aws-oncloudai.com\/zh_hk\/manage-the-aws-cli-efficiently-using-aws-configure\/","title":{"rendered":"\u4f7f\u7528aws configure \u9ad8\u6548\u7ba1\u7406AWS CLI"},"content":{"rendered":"<p>\u5728\u65e5\u5e38\u7684\u96f2\u7aef\u4e0a\u904b\u7dad\u8207\u958b\u767c\u4e2d\uff0c<strong>AWS CLI\uff08Command Line Interface\uff09<\/strong> \u662f\u5de5\u7a0b\u5e2b\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u4e4b\u4e00\u3002\u5b83\u80fd\u5920\u900f\u904e\u547d\u4ee4\u5217\u76f4\u63a5\u547c\u53ebAWS \u670d\u52d9API\uff0c\u5927\u5927\u63d0\u9ad8\u7ba1\u7406\u6548\u7387\u3002\u800caws configure\uff0c\u6b63\u662f\u9032\u5165AWS CLI \u4e16\u754c\u7684\u7b2c\u4e00\u6b65\u3002<\/p>\n<p>\u4f5c\u70baAWS \u5b98\u65b9\u6388\u6b0a\u4ee3\u7406\u5546\uff0c\u6211\u5011\u5728\u8207\u4f01\u696d\u5ba2\u6236\u5408\u4f5c\u7684\u904e\u7a0b\u4e2d\uff0c\u7d93\u5e38\u767c\u73fe\u5718\u968a\u5728\u521d\u6b21\u4f7f\u7528AWS CLI \u6642\uff0c\u5c0daws configure \u7684\u7406\u89e3\u548c\u914d\u7f6e\u5b58\u5728\u7591\u554f\u3002\u672c\u6587\u5c07\u8a73\u7d30\u89e3\u6790aws configure \u7684\u89d2\u8272\u3001\u4f7f\u7528\u65b9\u6cd5\u53ca\u6700\u4f73\u5be6\u8e10\uff0c\u5354\u52a9\u4f01\u696d\u66f4\u5feb\u5efa\u7acb\u6a19\u6e96\u5316\u3001\u53ef\u64f4\u5c55\u7684\u96f2\u7aef\u4e0a\u5de5\u4f5c\u6d41\u7a0b\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>\u4ec0\u9ebc\u662faws configure\uff1f<\/h4>\n<p>aws configure \u662fAWS CLI \u63d0\u4f9b\u7684\u4e00\u500b\u8a2d\u5b9a\u6307\u4ee4\uff0c\u7528\u65bc\u521d\u59cb\u5316\u548c\u7ba1\u7406CLI \u7684\u8a8d\u8b49\u8207\u9810\u8a2d\u53c3\u6578\u3002\u57f7\u884c\u6307\u4ee4\u5f8c\uff0c\u4f7f\u7528\u8005\u6703\u88ab\u63d0\u793a\u8f38\u5165\u4ee5\u4e0b\u95dc\u9375\u8cc7\u8a0a\uff1a<\/p>\n<ol>\n<li><strong>AWS Access Key ID<\/strong><\/li>\n<li><strong>AWS Secret Access Key<\/strong><\/li>\n<li><strong>Default region name<\/strong>\uff08\u9810\u8a2d\u5340\u57df\uff09<\/li>\n<li><strong>Default output format<\/strong>\uff08\u9810\u8a2d\u8f38\u51fa\u683c\u5f0f\uff0c\u5982json\u3001text\u3001table\uff09<\/li>\n<\/ol>\n<p>\u9019\u4e9b\u8cc7\u8a0a\u6703\u88ab\u5132\u5b58\u5230\u672c\u5730\u7684\u8a2d\u5b9a\u6a94\uff1a<\/p>\n<ul>\n<li>~\/.aws\/credentials\uff1a\u5b58\u653eAccess Key<\/li>\n<li>~\/.aws\/config\uff1a\u5b58\u653e\u9810\u8a2d\u5340\u57df\u3001\u8f38\u51fa\u683c\u5f0f\u7b49<\/li>\n<\/ul>\n<h4><\/h4>\n<h4>\u70ba\u4ec0\u9ebc\u4f01\u696d\u9700\u8981\u95dc\u6ce8aws configure<\/h4>\n<p>\u5f88\u591a\u4f01\u696d\u5728\u4f7f\u7528AWS \u6642\uff0c\u6703\u7fd2\u6163\u5728\u63a7\u5236\u53f0\u64cd\u4f5c\u3002\u4f46\u96a8\u8457\u5718\u968a\u898f\u6a21\u64f4\u5927\u53ca\u696d\u52d9\u8907\u96dc\u5ea6\u63d0\u5347\uff0c<strong>CLI \u8207\u81ea\u52d5\u5316\u8173\u672c<\/strong> \u5c31\u8b8a\u5f97\u975e\u5e38\u91cd\u8981\uff0c\u800caws configure \u662f\u9019\u4e00\u5207\u7684\u57fa\u790e\u3002<\/p>\n<p>\u5e7e\u500b\u6838\u5fc3\u539f\u56e0\uff1a<\/p>\n<ul>\n<li><strong>\u5b89\u5168\u6027<\/strong>\uff1a\u900f\u904e\u6307\u6d3e\u4e0d\u540cIAM \u4f7f\u7528\u8005\/\u89d2\u8272\u7684Access Key\uff0c\u53ef\u4ee5\u5be6\u73fe\u66f4\u7d30\u7c92\u5ea6\u7684\u6b0a\u9650\u63a7\u5236\u3002<\/li>\n<li><strong>\u6548\u7387<\/strong>\uff1a\u914d\u7f6e\u9810\u8a2d\u5340\u57df\u548c\u8f38\u51fa\u683c\u5f0f\u5f8c\uff0c\u65e5\u5e38\u64cd\u4f5c\u7121\u9700\u91cd\u8907\u8f38\u5165\u53c3\u6578\u3002<\/li>\n<li><strong>\u591a\u74b0\u5883\u652f\u63f4<\/strong>\uff1a\u652f\u63f4\u914d\u7f6e\u591a\u500bProfile\uff08\u5982\u958b\u767c\u3001\u6e2c\u8a66\u3001\u751f\u7522\uff09\uff0c\u5feb\u901f\u5207\u63db\uff0c\u907f\u514d\u8aa4\u64cd\u4f5c\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>\u4f7f\u7528\u7bc4\u4f8b<\/h4>\n<h5>1. \u57fa\u672c\u914d\u7f6e<\/h5>\n<p><span style=\"background-color: #999999;\">aws configure<\/span><\/p>\n<p>\u8f38\u5165\u8cc7\u8a0a\u5f8c\uff0cCLI \u6703\u7522\u751f\u8a2d\u5b9a\u6a94\u3002\u6b64\u5f8c\u5373\u53ef\u904b\u884c\uff1a<\/p>\n<p><span style=\"background-color: #999999;\">aws s3 ls<\/span><\/p>\n<p>\u76f4\u63a5\u5217\u51faS3 \u5132\u5b58\u6876\u3002<\/p>\n<h5>2. \u8a2d\u5b9a\u591a\u500bProfile<\/h5>\n<p>\u5728\u4f01\u696d\u74b0\u5883\u4e0b\uff0c\u4e0d\u540c\u5e33\u865f\u6216\u74b0\u5883\u5f80\u5f80\u9700\u8981\u55ae\u7368\u914d\u7f6e\uff1a<\/p>\n<p><span style=\"background-color: #999999;\">aws configure \u2013profile dev<\/span><\/p>\n<p><span style=\"background-color: #999999;\">aws configure \u2013profile prod<\/span><\/p>\n<p>\u8abf\u7528\u6642\uff1a<\/p>\n<p><span style=\"background-color: #999999;\">aws s3 ls \u2013profile prod<\/span><\/p>\n<h5>3. \u4fee\u6539\u914d\u7f6e<\/h5>\n<p>\u5982\u679c\u8981\u4fee\u6539\u67d0\u500b\u53c3\u6578\uff0c\u53ef\u4ee5\u76f4\u63a5\u904b\u4f5c\uff1a<\/p>\n<p><span style=\"background-color: #999999;\">aws configure set region ap-northeast-1 \u2013profile dev<\/span><\/p>\n<p>&nbsp;<\/p>\n<h4>\u6700\u4f73\u5be6\u8e10\u5efa\u8b70<\/h4>\n<p><strong>1.\u907f\u514d\u786c\u7de8\u78bc\u5bc6\u9470<\/strong><\/p>\n<p>\u5207\u52ff\u5728\u7a0b\u5f0f\u78bc\u4e2d\u76f4\u63a5\u5beb\u5165Access Key\u3002\u5efa\u8b70\u505a\u6cd5\u662f\u900f\u904eaws configure \u7ba1\u7406\u672c\u6a5f\u6191\u8b49\uff0c\u6216\u4f7f\u7528 <strong>AWS IAM Role<\/strong>\uff08\u5c24\u5176\u5728EC2\u3001ECS\u3001Lambda \u7b49\u74b0\u5883\uff09\u3002<\/p>\n<p><strong>2.\u4f7f\u7528Profiles \u7ba1\u7406\u591a\u74b0\u5883<\/strong><\/p>\n<p>\u5efa\u8b70\u6bcf\u500b\u5718\u968a\u6210\u54e1\u70ba\u4e0d\u540c\u5e33\u865f\u3001\u5340\u57df\u5efa\u7acbProfile\uff0c\u660e\u78ba\u5340\u5206 <strong>\u958b\u767c\u3001\u6e2c\u8a66\u3001\u751f\u7522<\/strong>\uff0c\u964d\u4f4e\u8aa4\u64cd\u4f5c\u98a8\u96aa\u3002<\/p>\n<p><strong>3.\u7d50\u5408MFA \u63d0\u5347\u5b89\u5168<\/strong><\/p>\n<p>\u5728\u9ad8\u5b89\u5168\u9700\u6c42\u60c5\u5883\uff08\u91d1\u878d\u3001\u91ab\u7642\u7b49\uff09\uff0c\u53ef\u900f\u904eAWS CLI \u914d\u5408MFA\uff08\u591a\u56e0\u5b50\u8a8d\u8b49\uff09\u9032\u4e00\u6b65\u52a0\u5f37\u9632\u8b77\u3002<\/p>\n<p><strong>4.\u7248\u672c\u7ba1\u7406\u8207\u5718\u968a\u7d71\u4e00<\/strong><\/p>\n<p>\u5728\u4f01\u696d\u5167\u90e8\uff0c\u5efa\u8b70\u7d71\u4e00AWS CLI \u7684\u7248\u672c\uff0c\u4e26\u64b0\u5beb\u5718\u968a\u5167\u90e8\u7684aws configure \u8a2d\u5b9a\u624b\u518a\uff0c\u78ba\u4fdd\u4e00\u81f4\u6027\u3002<\/p>\n<p>&nbsp;<\/p>\n<h4>\u5728\u96f2\u7aef\uff1a<\/h4>\n<p>\u4f5c\u70baAWS \u4ee3\u7406\u5546\uff0c\u6211\u5011\u5728\u5be6\u969b\u843d\u5730\u4e2d\uff0c\u53ef\u4ee5\u70ba\u5ba2\u6236\u63d0\u4f9b\u4ee5\u4e0b\u589e\u503c\u670d\u52d9\uff1a<\/p>\n<ul>\n<li><strong>\u521d\u59cb\u914d\u7f6e\u6307\u5c0e<\/strong>\uff1a\u5e6b\u52a9\u4f01\u696d\u5feb\u901f\u5b8c\u6210CLI \u74b0\u5883\u642d\u5efa\u8207aws configure \u521d\u59cb\u5316\u3002<\/li>\n<li><strong>\u591a\u5e33\u865f\u7ba1\u7406\u65b9\u6848<\/strong>\uff1a\u7d50\u5408AWS Organizations \u548cIAM\uff0c\u5efa\u69cb\u5b89\u5168\u3001\u53ef\u64f4\u5145\u7684\u591a\u5e33\u865f\u7ba1\u7406\u67b6\u69cb\u3002<\/li>\n<li><strong>\u81ea\u52d5\u5316\u843d\u5730<\/strong>\uff1a\u57fa\u65bcaws configure \u8a2d\u5b9a\u6587\u4ef6\uff0c\u5efa\u69cbTerraform\u3001CloudFormation\u3001CI\/CD \u7684\u7d71\u4e00\u6191\u8b49\u7ba1\u7406\u65b9\u6848\u3002<\/li>\n<li><strong>\u5b89\u5168\u5408\u898f\u5be9\u8a08<\/strong>\uff1a\u5b9a\u671f\u6aa2\u67e5\u4f01\u696d\u672c\u5730\u6191\u8b49\u7ba1\u7406\u65b9\u5f0f\uff0c\u78ba\u4fdd\u6eff\u8db3\u91d1\u878d\u3001\u91ab\u7642\u3001\u8de8\u5883\u96fb\u5546\u7b49\u884c\u696d\u7684\u5408\u898f\u8981\u6c42\u3002<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>\u7d50\u8a9e<\/h4>\n<p>aws configure \u96d6\u7136\u53ea\u662f\u4e00\u500b\u7c21\u55ae\u7684\u521d\u59cb\u5316\u6307\u4ee4\uff0c\u4f46\u537b\u662f\u4f01\u696d\u9ad8\u6548\u3001\u5b89\u5168\u4f7f\u7528AWS CLI \u7684\u8d77\u9ede\u3002\u5408\u7406\u5229\u7528Profiles\u3001\u5b89\u5168\u914d\u7f6e\u548c\u6700\u4f73\u5be6\u8e10\uff0c\u80fd\u5920\u70ba\u5718\u968a\u7684\u65e5\u5e38\u958b\u767c\u8207\u7dad\u904b\u6253\u4e0b\u5805\u5be6\u57fa\u790e\u3002<\/p>\n<p>\u4f5c\u70baAWS \u5b98\u65b9\u6388\u6b0a\u4ee3\u7406\u5546\uff0c\u6211\u5011\u4e0d\u50c5\u80fd\u5e6b\u52a9\u5ba2\u6236\u7406\u89e3CLI \u7684\u4f7f\u7528\u65b9\u6cd5\uff0c\u66f4\u80fd\u63d0\u4f9b <strong>\u5f9e\u914d\u7f6e\u5230\u843d\u5730\u7684\u5168\u6d41\u7a0b\u652f\u6301<\/strong>\uff0c\u8b93\u4f01\u696d\u5728\u96f2\u7aef\u4e0a\u7dad\u904b\u66f4\u6709\u6548\u7387\u3001\u66f4\u5b89\u5168\u3002<\/p>","protected":false},"excerpt":{"rendered":"<p>\u5728\u65e5\u5e38\u7684\u96f2\u7aef\u4e0a\u904b\u7dad\u8207\u958b\u767c\u4e2d\uff0cAWS CLI\uff08Command Line Interface\uff09 \u662f\u5de5\u7a0b\u5e2b\u4e0d\u53ef\u6216\u7f3a\u7684\u5de5\u5177\u4e4b\u4e00\u3002\u5b83\u80fd\u5920\u900f\u904e\u547d\u4ee4\u5217\u76f4\u63a5\u547c\u53ebAWS \u670d\u52d9API\uff0c\u5927\u5927\u63d0\u9ad8\u7ba1\u7406\u6548\u7387\u3002\u800caws configure\uff0c\u6b63\u662f\u9032\u5165AWS CLI \u4e16\u754c\u7684\u7b2c\u4e00\u6b65\u3002<\/p>\n<p>\u4f5c\u70baAWS \u5b98\u65b9\u6388\u6b0a\u4ee3\u7406\u5546\uff0c\u6211\u5011\u5728\u8207\u4f01\u696d\u5ba2\u6236\u5408\u4f5c\u7684\u904e\u7a0b\u4e2d\uff0c\u7d93\u5e38\u767c\u73fe\u5718\u968a\u5728\u521d\u6b21\u4f7f\u7528AWS CLI \u6642\uff0c\u5c0daws configure \u7684\u7406\u89e3\u548c\u914d\u7f6e\u5b58\u5728\u7591\u554f\u3002\u672c\u6587\u5c07\u8a73\u7d30\u89e3\u6790aws configure \u7684\u89d2\u8272\u3001\u4f7f\u7528\u65b9\u6cd5\u53ca\u6700\u4f73\u5be6\u8e10\uff0c\u5354\u52a9\u4f01\u696d\u66f4\u5feb\u5efa\u7acb\u6a19\u6e96\u5316\u3001\u53ef\u64f4\u5c55\u7684\u96f2\u7aef\u4e0a\u5de5\u4f5c\u6d41\u7a0b\u3002<\/p>","protected":false},"author":1,"featured_media":3884,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[65],"tags":[],"class_list":["post-3883","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technical-sharing"],"_links":{"self":[{"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/posts\/3883","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/comments?post=3883"}],"version-history":[{"count":1,"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/posts\/3883\/revisions"}],"predecessor-version":[{"id":3885,"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/posts\/3883\/revisions\/3885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/media\/3884"}],"wp:attachment":[{"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/media?parent=3883"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/categories?post=3883"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aws-oncloudai.com\/zh_hk\/wp-json\/wp\/v2\/tags?post=3883"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}