

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 映像建置器的 Identity and Access Management 整合
<a name="security-iam"></a>

**Topics**
+ [目標對象](#security-iam-audience)
+ [使用身分驗證](#security-iam-authentication)
+ [Image Builder 如何與 IAM 政策和角色搭配使用](security_iam_service-with-iam.md)
+ [在 Image Builder 中管理 S3 儲存貯體下載存取權的資料周邊](security-iam-data-perimeter.md)
+ [映像建置器身分型政策](security-iam-identity-based-policies.md)
+ [自訂工作流程的 IAM 許可](#security-iam-custom-workflows)
+ [Image Builder 資源型政策](#security-iam-resource-based-policies)
+ [使用 EC2 Image Builder 的 AWS 受管政策](security-iam-awsmanpol.md)
+ [使用映像建置器的 IAM 服務連結角色](image-builder-service-linked-role.md)
+ [對 Image Builder 中的 IAM 問題進行故障診斷](security_iam_troubleshoot.md)

## 目標對象
<a name="security-iam-audience"></a>

使用方式 AWS Identity and Access Management (IAM) 會根據您的角色而有所不同：
+ **服務使用者** — 若無法存取某些功能，請向管理員申請所需許可 (請參閱 [對 Image Builder 中的 IAM 問題進行故障診斷](security_iam_troubleshoot.md))
+ **服務管理員** — 負責設定使用者存取權並提交相關許可請求 (請參閱 [Image Builder 如何與 IAM 政策和角色搭配使用](security_iam_service-with-iam.md))
+ **IAM 管理員** — 撰寫政策以管理存取控制 (請參閱 [映像建置器身分型政策](security_iam_service-with-iam.md#security_iam_id-based-policy-examples))

## 使用身分驗證
<a name="security-iam-authentication"></a>

如需如何為 中的人員和程序提供身分驗證的詳細資訊 AWS 帳戶，請參閱《*IAM 使用者指南*》中的[身分](https://docs.aws.amazon.com/IAM/latest/UserGuide/id.html)。

## 自訂工作流程的 IAM 許可
<a name="security-iam-custom-workflows"></a>

搭配 等特定步驟動作使用自訂工作流程時[RegisterImage](wfdoc-step-actions.md#wfdoc-step-action-register-image)，除了標準 Image Builder 受管政策之外，可能需要額外的 IAM 許可。本節說明自訂工作流程步驟動作所需的額外許可。

### RegisterImage 步驟動作許可
<a name="security-iam-registerimage-permissions"></a>

`RegisterImage` 步驟動作需要特定的 Amazon EC2 許可，才能註冊 AMIs並選擇性地擷取快照標籤。使用 `includeSnapshotTags` 參數時，需要額外的許可來描述快照。

**RegisterImage 步驟動作的必要許可：**

對於所有資源，允許下列動作：
+ `ec2:RegisterImage`
+ `ec2:DescribeSnapshots`

```
{
    "Version": "2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "ec2:RegisterImage",
                "ec2:DescribeSnapshots"
            ],
            "Resource": "*"
        },
        {
            "Effect": "Allow",
            "Action": [
                "ec2:CreateTags"
            ],
            "Resource": "arn:aws:ec2:*::image/*",
            "Condition": {
                "StringEquals": {
                    "ec2:CreateAction": "RegisterImage"
                }
            }
        }
    ]
}
```

**許可詳細資訊：**
+ `ec2:RegisterImage` - 從快照註冊新的 AMIs 時需要
+ `ec2:DescribeSnapshots` - 使用 `includeSnapshotTags: true`擷取快照標籤以與 AMI 標籤合併時需要
+ `ec2:CreateTags` - 將標籤套用至已註冊的 AMI 時需要，包括映像建置器預設標籤和合併快照標籤

**注意**  
只有在 `includeSnapshotTags` 參數設定為 時，才會使用 `ec2:DescribeSnapshots`許可`true`。如果您不使用此功能，您可以省略此許可。

**標籤合併行為：**

啟用 `includeSnapshotTags` 時，RegisterImage 步驟動作將：
+ 從區塊型設備映射中指定的第一個快照擷取標籤
+ 排除任何 AWS 預留標籤 （索引鍵開頭為 "aws：" 的標籤）
+ 將快照標籤與映像建置器的預設 AMI 註冊標籤合併
+ 當標籤索引鍵發生衝突時，優先使用 Image Builder 標籤

## Image Builder 資源型政策
<a name="security-iam-resource-based-policies"></a>

如需如何建立元件的詳細資訊，請參閱 [使用元件來自訂映像建置器映像](manage-components.md)。

### 限制映像建置器元件對特定 IP 地址的存取
<a name="sec-iam-resourcepol-restrict-component-by-ip"></a>

下列範例會將許可授予任何使用者，以在元件上執行任何映像建置器操作。不過，要求必須源自於條件中所指定的 IP 地址範圍。

此陳述式中的條件會識別允許之 Internet Protocol Version 4 (IPv4) IP 地址的 54.240.143.\$1 範圍，但有一個例外：54.240.143.188。

`Condition` 區塊使用 `IpAddress`和 `NotIpAddress`條件和 `aws:SourceIp` 條件金鑰，這是 AWS全局條件金鑰。如需這些條件索引鍵的詳細資訊，請參閱[在政策中指定條件](https://docs.aws.amazon.com/AmazonS3/latest/userguide/amazon-s3-policy-keys.html)。`aws:sourceIp` IPv4 值會使用標準 CIDR 表示法。如需詳細資訊，請參閱《IAM 使用者指南》**中的 [IP 地址條件運算子](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_IPAddress)。

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Id": "IBPolicyId1",
  "Statement": [
    {
      "Sid": "IPAllow",
      "Effect": "Allow",
      "Action": "imagebuilder:GetComponent",
      "Resource": "arn:aws:imagebuilder:*::examplecomponent/*",
      "Condition": {
         "IpAddress": {"aws:SourceIp": "54.240.143.0/24"},
         "NotIpAddress": {"aws:SourceIp": "54.240.143.188/32"} 
      } 
    } 
  ]
}
```

------