{"id":1765,"date":"2025-01-06T16:50:55","date_gmt":"2025-01-06T08:50:55","guid":{"rendered":"https:\/\/www.fanyamin.com\/wordpress\/?p=1765"},"modified":"2025-01-06T16:50:55","modified_gmt":"2025-01-06T08:50:55","slug":"aws-iam-%e7%9b%b8%e5%85%b3%e6%a6%82%e5%bf%b5","status":"publish","type":"post","link":"https:\/\/www.fanyamin.com\/wordpress\/?p=1765","title":{"rendered":"AWS IAM \u76f8\u5173\u6982\u5ff5"},"content":{"rendered":"<h3><strong>1. IAM Role\uff08IAM \u89d2\u8272\uff09<\/strong><\/h3>\n<p><strong>\u4ec0\u4e48\u662f IAM \u89d2\u8272\uff1f<\/strong><\/p>\n<ul>\n<li>IAM \u89d2\u8272\u662f AWS \u63d0\u4f9b\u7684\u4e00\u79cd <strong>\u8eab\u4efd<\/strong>\uff0c\u7c7b\u4f3c\u4e8e\u7528\u6237\uff0c\u4f46\u5b83\u4e0d\u662f\u4e3a\u7279\u5b9a\u4eba\u521b\u5efa\u7684\uff0c\u800c\u662f\u8d4b\u4e88 AWS \u670d\u52a1\u6216\u5176\u4ed6\u8eab\u4efd\u7684\u6743\u9650\u96c6\u5408\u3002<\/li>\n<li><strong>\u89d2\u8272\u7684\u7279\u70b9<\/strong>\uff1a\u4e34\u65f6\u6027\u3001\u9700\u8981\u901a\u8fc7\u67d0\u79cd\u673a\u5236\u201c\u626e\u6f14\u201d\uff08assume\uff09\u89d2\u8272\u540e\u624d\u80fd\u4f7f\u7528\u5b83\u7684\u6743\u9650\u3002<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528\u573a\u666f\uff1a<\/strong><\/p>\n<ul>\n<li>\u4e00\u4e2a EC2 \u5b9e\u4f8b\u9700\u8981\u8bbf\u95ee S3 \u5b58\u50a8\u6876\uff0c\u4f46\u4e0d\u9700\u8981\u4f7f\u7528\u957f\u671f\u5bc6\u94a5\uff08\u5982 Access Key \u548c Secret Key\uff09\u3002<\/li>\n<li>AWS Lambda \u51fd\u6570\u8c03\u7528 DynamoDB \u65f6\u9700\u8981\u4e34\u65f6\u6743\u9650\u3002<\/li>\n<\/ul>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><br \/>\n\u5047\u5982\u4e00\u4e2a\u89d2\u8272\u88ab\u6388\u4e88\u8bfb\u53d6 S3 \u7684\u6743\u9650\uff0c\u90a3\u4e48 EC2 \u6216 Lambda \u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u201c\u626e\u6f14\u201d\u8fd9\u4e2a\u89d2\u8272\u6765\u8bbf\u95ee S3\u3002<\/p>\n<hr \/>\n<h3><strong>2. IAM Policy\uff08IAM \u7b56\u7565\uff09<\/strong><\/h3>\n<p><strong>\u4ec0\u4e48\u662f IAM \u7b56\u7565\uff1f<\/strong><\/p>\n<ul>\n<li>IAM \u7b56\u7565\u662f\u7528\u6765 <strong>\u5b9a\u4e49\u6743\u9650<\/strong> \u7684\u6587\u6863\uff0c\u901a\u5e38\u4ee5 JSON \u683c\u5f0f\u7f16\u5199\u3002<\/li>\n<li>\u5b83\u89c4\u5b9a\u4e86\u201c<strong>\u8c01\u53ef\u4ee5\u505a\u4ec0\u4e48<\/strong>\u201d\uff0c\u5177\u4f53\u5b9a\u4e49\uff1a\n<ul>\n<li><strong>\u8c01<\/strong>\uff1a\u89d2\u8272\u3001\u7528\u6237\u6216\u7ec4\u3002<\/li>\n<li><strong>\u53ef\u4ee5\u505a\u4ec0\u4e48<\/strong>\uff1a\u5141\u8bb8\u8bbf\u95ee\u54ea\u4e9b AWS \u670d\u52a1\u6216\u8d44\u6e90\uff0c\u4ee5\u53ca\u53ef\u4ee5\u6267\u884c\u54ea\u4e9b\u64cd\u4f5c\uff08\u4f8b\u5982 <code>s3:GetObject<\/code>\uff09\u3002<\/li>\n<li><strong>\u9650\u5236\u6761\u4ef6<\/strong>\uff1a\u5982\u65f6\u95f4\u8303\u56f4\u3001IP \u5730\u5740\u7b49\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>\u7b56\u7565\u793a\u4f8b\uff08JSON\uff09\uff1a<\/strong><\/p>\n<pre><code class=\"language-json\">{\n  &quot;Version&quot;: &quot;2012-10-17&quot;,\n  &quot;Statement&quot;: [\n    {\n      &quot;Effect&quot;: &quot;Allow&quot;,\n      &quot;Action&quot;: &quot;s3:GetObject&quot;,\n      &quot;Resource&quot;: &quot;arn:aws:s3:::my-bucket-name\/*&quot;\n    }\n  ]\n}<\/code><\/pre>\n<ul>\n<li>\u4e0a\u8ff0\u7b56\u7565\u5141\u8bb8\u8bfb\u53d6 S3 \u4e2d <code>my-bucket-name<\/code> \u7684\u6240\u6709\u5bf9\u8c61\u3002<\/li>\n<\/ul>\n<p><strong>\u5206\u7c7b\uff1a<\/strong><\/p>\n<ul>\n<li><strong>\u7ba1\u7406\u578b\u7b56\u7565\uff08Managed Policy\uff09<\/strong>\uff1aAWS \u63d0\u4f9b\u7684\u901a\u7528\u7b56\u7565\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u7b56\u7565\uff08Custom Policy\uff09<\/strong>\uff1a\u7528\u6237\u81ea\u5df1\u521b\u5efa\u7684\u7b56\u7565\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>3. IAM Trust Policy\uff08IAM \u4fe1\u4efb\u7b56\u7565\uff09<\/strong><\/h3>\n<p><strong>\u4ec0\u4e48\u662f IAM \u4fe1\u4efb\u7b56\u7565\uff1f<\/strong><\/p>\n<ul>\n<li>\u4fe1\u4efb\u7b56\u7565\u5b9a\u4e49\u4e86 <strong>\u8c01\u53ef\u4ee5\u626e\u6f14\u4e00\u4e2a IAM \u89d2\u8272<\/strong>\u3002<\/li>\n<li>\u5982\u679c IAM \u7b56\u7565\u89c4\u5b9a\u4e86\u201c\u6743\u9650\u201d\uff0c\u90a3\u4e48 <strong>\u4fe1\u4efb\u7b56\u7565\u89c4\u5b9a\u4e86\u8c01\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u6743\u9650<\/strong>\u3002<\/li>\n<\/ul>\n<p><strong>\u5173\u952e\u70b9\uff1a<\/strong><\/p>\n<ul>\n<li>\u4fe1\u4efb\u7b56\u7565\u662f\u9644\u52a0\u5728 IAM \u89d2\u8272\u4e0a\u7684\u3002<\/li>\n<li>\u53ea\u6709\u88ab\u4fe1\u4efb\u7684\u5b9e\u4f53\uff08AWS \u670d\u52a1\u3001\u7528\u6237\u3001\u8d26\u6237\uff09\u624d\u80fd\u201c\u626e\u6f14\u201d\u8be5\u89d2\u8272\u3002<\/li>\n<\/ul>\n<p><strong>\u4fe1\u4efb\u7b56\u7565\u793a\u4f8b\uff08JSON\uff09\uff1a<\/strong><\/p>\n<pre><code class=\"language-json\">{\n  &quot;Version&quot;: &quot;2012-10-17&quot;,\n  &quot;Statement&quot;: [\n    {\n      &quot;Effect&quot;: &quot;Allow&quot;,\n      &quot;Principal&quot;: {\n        &quot;Service&quot;: &quot;ec2.amazonaws.com&quot;\n      },\n      &quot;Action&quot;: &quot;sts:AssumeRole&quot;\n    }\n  ]\n}<\/code><\/pre>\n<ul>\n<li>\u4e0a\u8ff0\u7b56\u7565\u8868\u793a\u5141\u8bb8 AWS \u7684 EC2 \u670d\u52a1\u626e\u6f14\u8be5\u89d2\u8272\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>4. IAM Role Anywhere<\/strong><\/h3>\n<p><strong>\u4ec0\u4e48\u662f IAM Role Anywhere\uff1f<\/strong><\/p>\n<ul>\n<li>IAM Role Anywhere \u662f AWS \u63d0\u4f9b\u7684\u529f\u80fd\uff0c\u5141\u8bb8\u4f60\u5728 <strong>\u672c\u5730\u670d\u52a1\u5668\u6216\u5176\u4ed6\u975e AWS \u73af\u5883<\/strong> \u4f7f\u7528 IAM \u89d2\u8272\u6765\u8bbf\u95ee AWS \u670d\u52a1\u3002<\/li>\n<li>\u5b83\u901a\u8fc7 <strong>X.509 \u8bc1\u4e66<\/strong> \u6765\u9a8c\u8bc1\u8eab\u4efd\u5e76\u6388\u4e88\u4e34\u65f6\u6743\u9650\u3002<\/li>\n<\/ul>\n<p><strong>\u89e3\u51b3\u7684\u95ee\u9898\uff1a<\/strong><\/p>\n<ul>\n<li>\u5728\u975e AWS \u73af\u5883\u4e2d\uff0c\u4f60\u53ef\u80fd\u9700\u8981\u8bbf\u95ee AWS \u670d\u52a1\uff08\u5982 S3\u3001DynamoDB\uff09\uff0c\u4f46\u4f20\u7edf\u4e0a\u9700\u8981\u4f7f\u7528\u957f\u671f\u51ed\u636e\uff08Access Key \u548c Secret Key\uff09\u3002<\/li>\n<li>IAM Role Anywhere \u63d0\u4f9b\u4e86\u66f4\u5b89\u5168\u7684\u66ff\u4ee3\u65b9\u6848\uff0c\u5141\u8bb8\u57fa\u4e8e\u8bc1\u4e66\u7684\u8ba4\u8bc1\uff0c\u907f\u514d\u957f\u671f\u5bc6\u94a5\u6cc4\u9732\u98ce\u9669\u3002<\/li>\n<\/ul>\n<p><strong>\u5de5\u4f5c\u539f\u7406\uff1a<\/strong><\/p>\n<ol>\n<li>\u521b\u5efa\u4e00\u4e2a IAM \u89d2\u8272\u5e76\u9644\u52a0\u5fc5\u8981\u6743\u9650\u3002<\/li>\n<li>\u914d\u7f6e\u4fe1\u4efb\u7b56\u7565\uff0c\u5141\u8bb8 Role Anywhere \u8ba4\u8bc1\u7684\u5b9e\u4f53\u626e\u6f14\u8be5\u89d2\u8272\u3002<\/li>\n<li>\u5728\u672c\u5730\u7cfb\u7edf\u4e2d\u5b89\u88c5\u5e76\u914d\u7f6e\u8bc1\u4e66\u3002<\/li>\n<li>\u4f7f\u7528 IAM Role Anywhere SDK \u81ea\u52a8\u8bf7\u6c42\u4e34\u65f6\u51ed\u636e\u8bbf\u95ee AWS \u670d\u52a1\u3002<\/li>\n<\/ol>\n<p><strong>\u9002\u7528\u573a\u666f\uff1a<\/strong><\/p>\n<ul>\n<li>\u6570\u636e\u4e2d\u5fc3\u6216\u672c\u5730\u670d\u52a1\u5668\u9700\u8981\u5b89\u5168\u5730\u8bbf\u95ee AWS\u3002<\/li>\n<li>\u4f7f\u7528\u975e AWS \u4e91\u670d\u52a1\uff08\u5982 GCP \u6216 Azure\uff09\u65f6\u9700\u8981\u8de8\u4e91\u8bbf\u95ee AWS\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3><strong>\u603b\u7ed3<\/strong><\/h3>\n<table>\n<thead>\n<tr>\n<th><strong>\u6982\u5ff5<\/strong><\/th>\n<th><strong>\u5b9a\u4e49<\/strong><\/th>\n<th><strong>\u5173\u952e\u70b9<\/strong><\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><strong>IAM Role<\/strong><\/td>\n<td>AWS \u670d\u52a1\u6216\u5176\u4ed6\u8eab\u4efd\u4f7f\u7528\u7684\u6743\u9650\u96c6\u5408\uff0c\u9700\u4e34\u65f6\u626e\u6f14\u3002<\/td>\n<td>\u89d2\u8272\u672c\u8eab\u65e0\u56fa\u5b9a\u5bc6\u94a5\uff0c\u901a\u8fc7\u673a\u5236\uff08\u5982\u4fe1\u4efb\u7b56\u7565\uff09\u6388\u4e88\u4e34\u65f6\u6743\u9650\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>IAM Policy<\/strong><\/td>\n<td>\u5b9a\u4e49\u4e86\u201c\u53ef\u4ee5\u505a\u4ec0\u4e48\u201d\u7684\u6743\u9650\u7b56\u7565\u6587\u6863\u3002<\/td>\n<td>\u5141\u8bb8\u6216\u62d2\u7edd\u8bbf\u95ee AWS \u8d44\u6e90\u7684\u89c4\u5219\uff0c\u4ee5 JSON \u683c\u5f0f\u5b9a\u4e49\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>IAM Trust Policy<\/strong><\/td>\n<td>\u5b9a\u4e49\u4e86\u201c\u8c01\u53ef\u4ee5\u626e\u6f14\u8be5\u89d2\u8272\u201d\u7684\u7b56\u7565\u3002<\/td>\n<td>\u7528\u4e8e\u89d2\u8272\u7684\u5b89\u5168\u6027\u63a7\u5236\uff0c\u5e38\u7528\u4e8e EC2\u3001Lambda \u7b49\u670d\u52a1\u7684\u6388\u6743\u3002<\/td>\n<\/tr>\n<tr>\n<td><strong>IAM Role Anywhere<\/strong><\/td>\n<td>\u5141\u8bb8\u672c\u5730\u73af\u5883\u901a\u8fc7\u89d2\u8272\u8bbf\u95ee AWS \u670d\u52a1\u7684\u529f\u80fd\u3002<\/td>\n<td>\u57fa\u4e8e\u8bc1\u4e66\u8ba4\u8bc1\uff0c\u907f\u514d\u4f7f\u7528\u957f\u671f\u5bc6\u94a5\uff0c\u662f\u6df7\u5408\u4e91\u573a\u666f\u4e0b\u7684\u5b89\u5168\u89e3\u51b3\u65b9\u6848\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u901a\u8fc7\u8fd9\u4e9b\u673a\u5236\uff0cAWS \u63d0\u4f9b\u4e86\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u6743\u9650\u7ba1\u7406\u529f\u80fd\uff0c\u9002\u7528\u4e8e\u5404\u79cd\u573a\u666f\uff01 \ud83d\ude0a<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. IAM Role\uff08IAM \u89d2\u8272\uff09 \u4ec0\u4e48\u662f IAM \u89d2\u8272\uff1f IAM \u89d2\u8272\u662f AWS \u63d0\u4f9b\u7684\u4e00\u79cd \u8eab\u4efd\uff0c\u7c7b\u4f3c\u4e8e\u7528\u6237\uff0c\u4f46\u5b83\u4e0d\u662f\u4e3a\u7279\u5b9a\u4eba\u521b\u5efa\u7684\uff0c\u800c\u662f\u8d4b\u4e88 AWS \u670d\u52a1\u6216\u5176\u4ed6\u8eab\u4efd\u7684\u6743\u9650\u96c6\u5408\u3002 \u89d2\u8272\u7684\u7279\u70b9\uff1a\u4e34\u65f6\u6027\u3001\u9700\u8981\u901a\u8fc7\u67d0\u79cd\u673a\u5236\u201c\u626e\u6f14\u201d\uff08assume\uff09\u89d2\u8272\u540e\u624d\u80fd\u4f7f\u7528\u5b83\u7684\u6743\u9650\u3002 \u4f7f\u7528\u573a\u666f\uff1a \u4e00\u4e2a EC2 \u5b9e\u4f8b\u9700\u8981\u8bbf\u95ee S3 \u5b58\u50a8\u6876\uff0c\u4f46\u4e0d\u9700\u8981\u4f7f\u7528\u957f\u671f\u5bc6\u94a5\uff08\u5982 Access Key \u548c Secret Key\uff09\u3002 AWS Lambda \u51fd\u6570\u8c03\u7528 DynamoDB \u65f6\u9700\u8981\u4e34\u65f6\u6743\u9650\u3002 \u793a\u4f8b\uff1a \u5047\u5982\u4e00\u4e2a\u89d2\u8272\u88ab\u6388\u4e88\u8bfb\u53d6 S3 \u7684\u6743\u9650\uff0c\u90a3\u4e48 EC2 \u6216 Lambda \u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u201c\u626e\u6f14\u201d\u8fd9\u4e2a\u89d2\u8272\u6765\u8bbf\u95ee S3\u3002 2. IAM Policy\uff08IAM \u7b56\u7565\uff09 \u4ec0\u4e48\u662f IAM \u7b56\u7565\uff1f IAM \u7b56\u7565\u662f\u7528\u6765 \u5b9a\u4e49\u6743\u9650 \u7684\u6587\u6863\uff0c\u901a\u5e38\u4ee5 JSON \u683c\u5f0f\u7f16\u5199\u3002 \u5b83\u89c4\u5b9a\u4e86\u201c\u8c01\u53ef\u4ee5\u505a\u4ec0\u4e48\u201d\uff0c\u5177\u4f53\u5b9a\u4e49\uff1a \u8c01\uff1a\u89d2\u8272\u3001\u7528\u6237\u6216\u7ec4\u3002 [&hellip;] <a class=\"read-more\" href=\"https:\/\/www.fanyamin.com\/wordpress\/?p=1765\" title=\"Permanent Link to: AWS IAM \u76f8\u5173\u6982\u5ff5\">&rarr;Read&nbsp;more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1765","post","type-post","status-publish","format-standard","hentry","category-5"],"_links":{"self":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1765"}],"collection":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1765"}],"version-history":[{"count":1,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1765\/revisions"}],"predecessor-version":[{"id":1766,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/1765\/revisions\/1766"}],"wp:attachment":[{"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1765"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1765"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.fanyamin.com\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1765"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}