{"id":10718,"date":"2023-04-18T13:25:30","date_gmt":"2023-04-18T05:25:30","guid":{"rendered":"http:\/\/123.57.164.21\/?p=10718"},"modified":"2023-04-18T13:25:30","modified_gmt":"2023-04-18T05:25:30","slug":"aws-cli-%e5%ae%89%e8%a3%85%e9%85%8d%e7%bd%ae","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=10718","title":{"rendered":"AWS CLI \u5b89\u88c5\u914d\u7f6e"},"content":{"rendered":"\n<p>\u8bbf\u95eeAWS\u7684\u670d\u52a1\uff0c\u57fa\u672c\u6709\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\uff0c\u672c\u6587\u5c06\u4f1a\u4ecb\u7ecd\u5982\u4f55\u521d\u59cb\u5316\u914d\u7f6eAWS \u547d\u4ee4\u884c\u63a5\u53e3\uff08Command Line Interface\uff0c CLI\uff09\uff0c\u4ee5\u8bbf\u95eeAWS\u670d\u52a1\u3002<\/p>\n\n\n\n<ul><li>\u200bAWS \u7ba1\u7406\u63a7\u5236\u53f0<\/li><li>\u200bAWS \u200b\u547d\u4ee4\u884c\u63a5\u53e3\u200b\u200b<\/li><li>\u200bAWS API<\/li><\/ul>\n\n\n\n<p><strong>1 AWS Command Line Interface \u662f\u4ec0\u4e48\uff1f<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>AWS Command Line Interface (AWS CLI) \u662f\u4e00\u79cd\u5f00\u6e90\u5de5\u5177\uff0c\u8ba9\u60a8\u80fd\u591f\u5728\u547d\u4ee4\u884c\u7ec8\u7aef\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u547d\u4ee4\u4e0eAWS \u670d\u52a1\u8fdb\u884c\u4ea4\u4e92\u3002\u4f7f\u7528 AWS CLI \u8fd0\u884c\u547d\u4ee4\u65f6\uff0c\u53ef\u4ece\u7ec8\u7aef\u7a0b\u5e8f\u7684\u547d\u4ee4\u63d0\u793a\u7b26\u5b9e\u73b0\u4e0e\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684 AWS Management Console\u6240\u63d0\u4f9b\u7684\u529f\u80fd\u7b49\u540c\u7684\u529f\u80fd\u3002\u5e38\u7528\u7684\u547d\u4ee4\u884c\u7ec8\u7aef\u7a0b\u5e8f\uff0c\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\u800c\u6709\u6240\u4e0d\u540c\uff1a<\/p>\n\n\n\n<ul><li>Linux Shell<\/li><\/ul>\n\n\n\n<p>\u4f7f\u7528\u5e38\u89c1Shell \u7a0b\u5e8f\uff08\u4f8b\u5982 bash\u3001zsh \u548c tcsh\uff09\u5728 Linux \u6216 macOS \u4e2d\u8fd0\u884c\u547d\u4ee4\u3002<\/p>\n\n\n\n<ul><li>\u200bWindows \u547d\u4ee4\u884c<\/li><\/ul>\n\n\n\n<p>\u5728Windows \u4e0a\uff0c\u5728 Windows \u547d\u4ee4\u63d0\u793a\u7b26\uff08cmd\uff09\u5904\u6216\u5728 PowerShell \u4e2d\u8fd0\u884c\u547d\u4ee4\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7\u8fdc\u7a0b\u7ec8\u7aef\u7a0b\u5e8f\uff08\u5982PuTTY \u6216 SSH\uff09\u5728 Amazon Elastic Compute Cloud (Amazon EC2) \u5b9e\u4f8b\u4e0a\u8fd0\u884c\u547d\u4ee4\uff0c\u6216\u8005\u4f7f \u7528AWS Systems Manager \u8fd0\u884c\u547d\u4ee4\u3002<\/p>\n\n\n\n<p>\u6240\u6709\u80fd\u591f\u901a\u8fc7AWS Management Console\u5b9e\u73b0\u7684\u64cd\u4f5c\uff0c\u5747\u53ef\u901a\u8fc7 AWS API \u548c AWS CLI \u5b9e\u73b0\u3002\u65b0\u7684 AWS IaaS \u529f\u80fd\u548c\u670d\u52a1\u5728\u53d1\u5e03\u65f6\u6216\u5728 180 \u5929\u53d1\u5e03\u671f\u5185\u90fd\u4f1a\u901a\u8fc7 API \u548c CLI \u63d0\u4f9b\u5168\u90e8 AWS Management Console \u529f\u80fd\u3002<\/p>\n\n\n\n<p><strong>2 AWS CLI\u7684\u5b89\u88c5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u6839\u636e\u81ea\u5df1\u7684\u64cd\u4f5c\u7cfb\u7edf\uff0c\u4e0b\u8f7d\u76f8\u5e94\u7684\u200b \u200b\u5b89\u88c5\u5305\u200b\u200b\u5b89\u88c5\u3002\u5b89\u88c5\u8fc7\u7a0b\u5f88\u7b80\u5355\uff0c\u5728\u6b64\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n\n\n\n<p>\u5728\u5b89\u88c5\u5b8c\u6210\u4e4b\u540e\uff0c\u8fd0\u884c\u4ee5\u4e0b\u4e24\u4e2a\u547d\u4ee4\u6765\u9a8c\u8bc1AWS CLI\u662f\u5426\u5b89\u88c5\u6210\u529f\u3002\u53c2\u8003\u4ee5\u4e0b\u793a\u4f8b\uff0c\u5728MacOS\u4e0a\u6253\u5f00Terminal\u7a0b\u5e8f\u3002\u5982\u679c\u662fWindows\u7cfb\u7edf\uff0c\u6253\u5f00cmd\u3002<\/p>\n\n\n\n<ul><li>\u200bwhere aws \/ which aws \u67e5\u770bAWS CLI\u5b89\u88c5\u8def\u5f84<\/li><li>\u200baws &#8211;version \u67e5\u770bAWS CLI\u7248\u672c<\/li><\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">carl@MBP-Carls-MacBook-Pro ~ % where aws\n\/usr\/local\/bin\/aws\ncarl@MBP-Carls-MacBook-Pro ~ % which aws\n\/usr\/local\/bin\/aws\ncarl@MBP-Carls-MacBook-Pro ~ % aws --version\naws-cli\/2.4.6 Python\/3.8.8 Darwin\/19.6.0exe\/x86_64 prompt\/off\n<\/pre>\n\n\n\n<p>\u63d0\u793a\uff1a<\/p>\n\n\n\n<p>AWS CLI v1\u548cv2\u4e24\u4e2a\u7248\u672c\u4f7f\u7528\u76f8\u540c\u7684aws\u547d\u4ee4\u3002\u5982\u679c\u4e24\u4e2a\u7248\u672c\u90fd\u5b89\u88c5\u4e86\uff0c\u542f\u52a8AWS CLI \u65f6\u4f1a\u542f\u52a8\u5728search path \u4e2d\u627e\u5230\u7684\u7b2c\u4e00\u4e2a\u7248\u672c\u3002\u5982\u679c\u4e4b\u524d\u5b89\u88c5\u4e86v1\u7248\u672c\uff0c\u53ef\u901a\u8fc7\u4ee5\u4e0b\u65b9\u5f0f\u89e3\u51b3\uff1a<\/p>\n\n\n\n<ul><li>\u63a8\u8350 \u2013 \u5378\u8f7dv1\uff0c\u4ec5\u4f7f\u7528v2\u3002<\/li><\/ul>\n\n\n\n<ul><li>\u5728\u76f8\u5bf9\u5e94\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u4f7f\u7528\u4e0d\u540c\u7684\u540d\u5b57\u4e3a\u5176\u4e2d\u7684\u4e00\u4e2aaws\u547d\u4ee4\u521b\u5efasymbolic link (symlink) oralias\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728Linux and macOS\u4e0a\u4f7f\u7528\u200b\u200b\u200b \u200bsymbolic link\u200b\u200b\u200b or \u200b \u200balias\u200b\u200b\u200b , \u6216\u5728Windows\u4e0a\u4f7f\u7528\u200b \u200bDOSKEY\u200b\u200b\u3002<\/li><\/ul>\n\n\n\n<p><strong>3 \u521d\u59cb\u5316\u914d\u7f6eAWS CLI<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u5728\u4f7f\u7528AWS CLI\u524d\uff0c\u53ef\u4f7f\u7528aws configure\u547d\u4ee4\uff0c\u5b8c\u6210\u521d\u59cb\u5316\u914d\u7f6e\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">carl@MBP-Carls-MacBook-Pro~ % aws configure\nAWS Access Key ID [None]: AKIA3GRZL6WIQEXAMPLE\nAWS Secret Access Key [None]: k+ci5r+hAcM3x61w1example\nDefault region name [None]: ap-east-1\nDefault output format [None]: json\n<\/pre>\n\n\n\n<p>AWS Access Key ID \u53caAWS Secret Access Key\u53ef\u5728AWS\u7ba1\u7406\u63a7\u5236\u53f0\u83b7\u53d6\uff0cAWS CLI\u5c06\u4f1a\u4f7f\u7528\u6b64\u4fe1\u606f\u4f5c\u4e3a\u7528\u6237\u540d\u3001\u5bc6\u7801\u8fde\u63a5AWS\u670d\u52a1\u3002<\/p>\n\n\n\n<p><br>\u200b\u200b\u70b9\u51fbAWS\u7ba1\u7406\u63a7\u5236\u53f0\u53f3\u4e0a\u89d2\u7684\u7528\u6237\u540d &#8211;> \u9009\u62e9Security Credentials<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/04\/image-174.png\" alt=\"\" class=\"wp-image-10719\" width=\"385\" height=\"220\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-174.png 780w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-174-300x172.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-174-768x439.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-174-230x132.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-174-350x200.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-174-480x274.png 480w\" sizes=\"(max-width: 385px) 100vw, 385px\" \/><\/figure><\/div>\n\n\n\n<p>\u70b9\u51fbCreate New Access Key\u4ee5\u521b\u5efa\u4e00\u5bf9Access Key ID \u53caSecret Access Key\uff0c\u5e76\u4fdd\u5b58\uff08\u4e14\u4ec5\u80fd\u5728\u521b\u5efa\u65f6\u4fdd\u5b58\uff09<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/04\/image-175.png\" alt=\"\" class=\"wp-image-10720\" width=\"444\" height=\"261\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-175.png 942w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-175-300x176.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-175-768x452.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-175-830x488.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-175-230x135.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-175-350x206.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-175-480x282.png 480w\" sizes=\"(max-width: 444px) 100vw, 444px\" \/><\/figure><\/div>\n\n\n\n<p>Default region name\uff0c\u7528\u4ee5\u6307\u5b9a\u8981\u8fde\u63a5\u7684AWS \u533a\u57df\u4ee3\u7801\u3002<\/p>\n\n\n\n<p>Default output format\uff0c\u7528\u4ee5\u6307\u5b9a\u547d\u4ee4\u884c\u8f93\u51fa\u5185\u5bb9\u7684\u683c\u5f0f\uff0c\u9ed8\u8ba4\u4f7f\u7528JSON\u4f5c\u4e3a\u6240\u6709\u8f93\u51fa\u7684\u683c\u5f0f\u3002\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4efb\u4e00\u683c\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">JSON(JavaScript Object Notation)\n\u200bYAML: \u4ec5\u5728 AWS CLI v2 \u7248\u672c\u4e2d\u53ef\u7528\n\u200bText\n\u200bTable<\/pre>\n\n\n\n<p><strong>4 \u914d\u7f6eAWS CLI profile<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u4e00\u822c\u4f01\u4e1a\u4f1a\u5c06IT\u73af\u5883\u5206\u4e3a\u8bf8\u5982\u751f\u4ea7\u73af\u5883\u3001UAT\u73af\u5883\u3001DEV\u73af\u5883\u7b49\uff0c\u5404\u73af\u5883\u7684\u533a\u57df\u6709\u53ef\u80fd\u4e0d\u540c\uff0c\u6240\u4f7f\u7528\u7684\u7528\u6237\u540d\u3001\u5bc6\u7801\u4e5f\u6709\u53ef\u80fd\u4e0d\u540c\uff0c\u5982\u679c\u6bcf\u6b21\u90fd\u9700\u8981\u4f7f\u7528aws configure\u5207\u6362\u73af\u5883\uff0c\u4f1a\u6bd4\u8f83\u9ebb\u70e6\uff0c\u800c\u4e14\u5bb9\u6613\u51fa\u9519\u3002\u90a3\u4e48\uff0c\u5982\u4f55\u5feb\u901f\u3001\u7b80\u5355\u3001\u65b9\u4fbf\u7684\u5728AWSCLI \u4e2d\u533a\u522b\u8fd9\u4e9b\u73af\u5883\u5462\uff1f\u53ef\u4ee5\u4f7f\u7528&#8211;profile\u53c2\u6570\u9884\u5148\u8bbe\u7f6e\u6240\u9700\u4e0d\u540c\u73af\u5883\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">carl@MBP-Carls-MacBook-Pro~ % aws configure --profile Production\nAWS Access Key ID [None]: AKIA3GRZL6WIQUEXAMPLE\nAWS Secret Access Key [None]: k+ci5r+hAcM3x61w1example\nDefault region name [None]: \nDefault output format [None]:\ncarl@MBP-Carls-MacBook-Pro~ % aws configure --profile UAT\nAWS Access Key ID [None]: AKIA3GRZL6WIQUEXAMPLE\nAWS Secret Access Key [None]: k+ci5r+hAcM3x61w1example\nDefault region name [None]: us-east-1\nDefault output format [None]: json\ncarl@MBP-Carls-MacBook-Pro~ % aws configure list-profiles\ndefault\nProduction\nUAT\n<\/pre>\n\n\n\n<p>\u901a\u8fc7\u4e0a\u8ff0\u793a\u4f8b\uff0c\u53ef\u4ee5\u89c2\u5bdf\u5230\uff0c\u6211\u4eec\u5728\u7b2c\u4e00\u6b21\u8fd0\u884caws configure\u547d\u4ee4\u65f6\uff0c\u5e76\u672a\u6307&#8211;profile\u53c2\u6570\uff0c\u6240\u4ee5\u9ed8\u8ba4\u4f1a\u4f7f\u7528default\u8fd9\u4e2aprofile\u3002<\/p>\n\n\n\n<p>\u901a\u8fc7aws configure\u547d\u4ee4\u6240\u914d\u7f6e\u7684\u4fe1\u606f\u90fd\u5b58\u50a8\u5230\u4e86\u8ba1\u7b97\u673a\u672c\u5730\u786c\u76d8\u4e0a\u7684config\u53caCredentials\u4e24\u4e2a\u6587\u4ef6\u4e2d\uff0c\u6587\u4ef6\u9ed8\u8ba4\u4fdd\u5b58\u8def\u5f84\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u7684\u4e0d\u540c\u800c\u4e0d\u540c<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-large is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/04\/image-176-1024x234.png\" alt=\"\" class=\"wp-image-10721\" width=\"605\" height=\"137\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-1024x234.png 1024w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-300x68.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-768x175.png 768w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-1536x350.png 1536w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-830x189.png 830w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-230x52.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-350x80.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176-480x109.png 480w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-176.png 1640w\" sizes=\"(max-width: 605px) 100vw, 605px\" \/><\/figure><\/div>\n\n\n\n<p>\u4ee5MacOS\u4e3a\u4f8b\uff0c\u5982\u4e0b\u56fe\uff1a<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/04\/image-177.png\" alt=\"\" class=\"wp-image-10722\" width=\"449\" height=\"374\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-177.png 740w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-177-300x250.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-177-230x191.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-177-350x291.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-177-480x400.png 480w\" sizes=\"(max-width: 449px) 100vw, 449px\" \/><\/figure><\/div>\n\n\n\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u56e0\u4e3aProduction profile\u7684region\u3001output\u5747\u4e3a\u9ed8\u8ba4\u503c\uff0c\u6240\u4ee5\u5728config\u6587\u4ef6\u4e2d\u5e76\u6ca1\u6709\u663e\u793a\u5b83\u4eec\u7684\u503c\u3002<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/123.57.164.21\/wp-content\/uploads\/2023\/04\/image-178.png\" alt=\"\" class=\"wp-image-10723\" width=\"328\" height=\"125\" srcset=\"https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-178.png 550w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-178-300x115.png 300w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-178-230x88.png 230w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-178-350x134.png 350w, https:\/\/92it.top\/wp-content\/uploads\/2023\/04\/image-178-480x183.png 480w\" sizes=\"(max-width: 328px) 100vw, 328px\" \/><\/figure><\/div>\n\n\n\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u4f7f\u7528aws configure\u547d\u4ee4\u5728\u914d\u7f6eprofile\u8fc7\u7a0b\u4e2d\u8f93\u5165\u7684access key id\uff08\u7528\u6237\u540d\uff09\u3001secret access key\uff08\u5bc6\u7801\uff09 \u5747\u88ab\u660e\u6587\u4fdd\u5b58\u5728\u4e86credentials\u6587\u4ef6\u4e2d\u3002<\/p>\n\n\n\n<p>\u53ef\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u67d0\u4e2aprofile\u7684\u914d\u7f6e\u3002profile\u7684\u503c\u5728\u8f93\u5165\u65f6\u533a\u5206\u5927\u5c0f\u5199\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">carl@MBP-Carls-MacBook-Pro~ % aws configure get region --profile UAT\nus-east-1\ncarl@MBP-Carls-MacBook-Pro~ % aws configure get region --profile default\nap-east-1<\/pre>\n\n\n\n<p><strong>5 \u9a8c\u8bc1\u5230AWS\u670d\u52a1\u7684\u8fde\u63a5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>\u51c6\u5907\u5c31\u7eea\uff0c\u73b0\u5728\u53ef\u4ee5\u9488\u5bf9\u67d0\u4e2aaws\u670d\u52a1\u6267\u884c\u76f8\u5e94\u64cd\u4f5c\u4e86\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u793a\u4f8b\u4e3a\u67e5\u770bProduction\u73af\u5883\u4e2d\u6240\u6709\u7684IAM\u7528\u6237\u5217\u8868\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">carl@MBP-Carls-MacBook-Pro ~ % aws iam list-users --profile Production\n{  \n \"Users\": [ \n    {      \n         \"Path\": \"\/\",\n         \"UserName\": \"yang\",         \n         \"UserId\": \"AIDA3EXAMPLE\",     \n         \"Arn\": \"arn:aws:iam::7**********1:user\/yang\",     \n         \"CreateDate\": \"2021-04-09T22:24:51+00:00\",     \n         \"PasswordLastUsed\": \"2021-05-28T07:19:45+00:00\"\n      },     \n      {         \n         \"Path\": \"\/\",       \n         \"UserName\": \"jiang\",        \n         \"UserId\": \"AIDA3EXAMPLE\",      \n         \"Arn\": \"arn:aws:iam::7**********1:user\/jiang\",      \n         \"CreateDate\": \"2021-05-24T02:56:01+00:00\",     \n         \"PasswordLastUsed\": \"2021-08-06T02:40:12+00:00\"  \n      },\n   ]\n}\n\n<\/pre>\n\n\n\n<p><strong>6.\u5bf9\u4e8e aws config \u548c credentials \u6587\u4ef6\u8865\u5145\u8bf4\u660e<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>AWS CLI\u4f7f\u7528<code>config<\/code>\u548c<code>credentials<\/code>\u6587\u4ef6\u6765\u5b58\u50a8\u8bbf\u95eeAWS\u8d44\u6e90\u6240\u9700\u7684\u914d\u7f6e\u548c\u51ed\u636e\u4fe1\u606f\u3002<\/p>\n\n\n\n<p><code>config<\/code>\u6587\u4ef6\u5b58\u50a8AWS CLI\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u4f8b\u5982\u9ed8\u8ba4\u7684AWS\u533a\u57df\u548c\u8f93\u51fa\u683c\u5f0f\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>config<\/code>\u6587\u4ef6\u4f4d\u4e8e<code>~\/.aws\/config<\/code>\u8def\u5f84\u4e0b\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f<code>config<\/code>\u6587\u4ef6\u7684\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[default]\nregion = us-west-2\noutput = json\n<\/pre>\n\n\n\n<p><code>credentials<\/code>\u6587\u4ef6\u5b58\u50a8AWS\u8bbf\u95ee\u51ed\u636e\uff0c\u5305\u62ecAWS\u8bbf\u95ee\u5bc6\u94a5\u548cAWS\u5bc6\u94a5ID\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>credentials<\/code>\u6587\u4ef6\u4f4d\u4e8e<code>~\/.aws\/credentials<\/code>\u8def\u5f84\u4e0b\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u662f<code>credentials<\/code>\u6587\u4ef6\u7684\u793a\u4f8b\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[default]\naws_access_key_id = YOUR_ACCESS_KEY\naws_secret_access_key = YOUR_SECRET_KEY<\/pre>\n\n\n\n<p>\u5728AWS CLI\u4e2d\uff0c<code>config<\/code>\u548c<code>credentials<\/code>\u6587\u4ef6\u662f\u5206\u5f00\u7684\u4e24\u4e2a\u6587\u4ef6\uff0c\u4f46\u662f\u5b83\u4eec\u4e4b\u95f4\u662f\u6709\u5173\u8054\u7684\u3002<\/p>\n\n\n\n<p><code>config<\/code>\u6587\u4ef6\u5b58\u50a8AWS CLI\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u4f8b\u5982\u9ed8\u8ba4\u7684AWS\u533a\u57df\u548c\u8f93\u51fa\u683c\u5f0f\u3002<code>credentials<\/code>\u6587\u4ef6\u5b58\u50a8AWS\u8bbf\u95ee\u51ed\u636e\uff0c\u5305\u62ecAWS\u8bbf\u95ee\u5bc6\u94a5\u548cAWS\u5bc6\u94a5ID\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e24\u4e2a\u6587\u4ef6\u90fd\u53ef\u4ee5\u5305\u542b\u4e00\u4e2a\u6216\u591a\u4e2a\u547d\u540d\u7684\u914d\u7f6e\u6587\u4ef6\uff08\u5373AWS\u914d\u7f6e\u6587\u4ef6\uff09\u3002\u6bcf\u4e2a\u914d\u7f6e\u6587\u4ef6\u90fd\u53ef\u4ee5\u6307\u5b9a\u7279\u5b9a\u7684AWS\u533a\u57df\u3001\u8f93\u51fa\u683c\u5f0f\u3001\u8bbf\u95ee\u51ed\u636e\u7b49\u7b49\u3002AWS CLI\u9ed8\u8ba4\u4f7f\u7528\u540d\u4e3a&#8221;default&#8221;\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4f46\u60a8\u4e5f\u53ef\u4ee5\u521b\u5efa\u5176\u4ed6\u914d\u7f6e\u6587\u4ef6\u6765\u6307\u5b9a\u4e0d\u540c\u7684AWS\u8d44\u6e90\u3001\u8bbf\u95ee\u51ed\u636e\u7b49\u3002<\/p>\n\n\n\n<p>\u8fd9\u4e24\u4e2a\u6587\u4ef6\u90fd\u662f\u4ee5INI\u683c\u5f0f\uff08\u5373\u4e00\u4e2a\u8282(section)\u7531\u4e00\u5bf9\u65b9\u62ec\u53f7\u5305\u542b\uff0c\u4e00\u4e2a\u8282\u4e2d\u5305\u542b\u591a\u4e2a\u952e\u503c\u5bf9\uff09\u8fdb\u884c\u7f16\u5199\u7684\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5305\u542b\u4e24\u4e2aAWS\u914d\u7f6e\u6587\u4ef6\u7684\u793a\u4f8b<code>config<\/code>\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[default]\nregion = us-west-2\noutput = json\n\n[profile prod]\nregion = us-east-1\noutput = text\n<\/pre>\n\n\n\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u5305\u542b\u4e24\u4e2aAWS\u8bbf\u95ee\u51ed\u636e\u7684\u793a\u4f8b<code>credentials<\/code>\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[default]\naws_access_key_id = YOUR_ACCESS_KEY\naws_secret_access_key = YOUR_SECRET_KEY\n\n[prod]\naws_access_key_id = YOUR_PROD_ACCESS_KEY\naws_secret_access_key = YOUR_PROD_SECRET_KEY\n<\/pre>\n\n\n\n<p>\u8bf7\u6ce8\u610f\uff0cAWS CLI\u4f1a\u5728\u5185\u90e8\u4f7f\u7528\u8fd9\u4e9b\u6587\u4ef6\u6765\u786e\u5b9a\u5982\u4f55\u8fde\u63a5\u5230AWS\u670d\u52a1\uff0c\u5e76\u4e14\u60a8\u53ef\u4ee5\u4f7f\u7528<code>--profile<\/code>\u9009\u9879\u6307\u5b9a\u8981\u4f7f\u7528\u7684AWS\u914d\u7f6e\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u4ee5\u4e0b\u547d\u4ee4\u5c06\u4f7f\u7528\u540d\u4e3a<code>prod<\/code>\u7684AWS\u914d\u7f6e\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">aws s3 ls --profile prod<\/pre>\n\n\n\n<p>\u4e5f\u53ef\u4ee5\u4f7f\u7528\u4e0b\u9762\u547d\u4ee4\u6307\u5b9aprofile<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">export AWS_PROFILE=pord<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8bbf\u95eeAWS\u7684\u670d\u52a1\uff0c\u57fa\u672c\u6709\u4ee5\u4e0b\u4e09\u79cd\u65b9\u5f0f\uff0c\u672c\u6587\u5c06\u4f1a\u4ecb\u7ecd\u5982\u4f55\u521d\u59cb\u5316\u914d\u7f6eAWS \u547d\u4ee4\u884c\u63a5\u53e3\uff08Command Line  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,9],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10718"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10718"}],"version-history":[{"count":3,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10718\/revisions"}],"predecessor-version":[{"id":10726,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/10718\/revisions\/10726"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}