

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

# 指派 IAM 許可以使用 Ground Truth
<a name="sms-security-permission"></a>

使用本節中的主題，了解如何使用 AWS Identity and Access Management (IAM) 受管和自訂政策來管理對 Ground Truth 和相關資源的存取。

您可以透過此頁面章節來了解下列資訊：
+ 如何建立 IAM 政策，授予使用者或角色建立標籤工作的許可。管理員可以使用 IAM 政策來限制對 Amazon SageMaker AI 和其他 Ground Truth 特定 AWS 服務的存取。
+ 如何建立 SageMaker AI *執行角色*。執行角色是您在建立標籤工作時所指定的角色。角色用於啟動和管理您的標籤工作。

以下是您可以在此頁面上找到的主題概觀：
+ 如果您要開始使用 Ground Truth，或者不需要使用案例的精細授權，建議您使用 IAM 受管政策，如[在 Ground Truth 使用 IAM 受管政策](sms-security-permissions-get-started.md)所述。
+ 在[授予 IAM 許可以使用 Amazon SageMaker Ground Truth 主控台](sms-security-permission-console-access.md)中了解使用 Ground Truth 主控台所需的權限。本節包含授予 IAM 實體許可，以建立和修改私有工作團隊、訂閱廠商工作團隊，及建立自訂標籤工作流程的政策範例。
+ 建立標籤工作時，您必須提供執行角色。使用 [為 Ground Truth 標籤工作建立 SageMaker AI 執行角色](sms-security-permission-execution-role.md) 來了解此角色所需的許可。

# 在 Ground Truth 使用 IAM 受管政策
<a name="sms-security-permissions-get-started"></a>

SageMaker AI 和 Ground Truth 提供可建立標籤工作的 AWS 受管政策。如要開始使用 Ground Truth，而且不需要使用案例的精細授權，建議您使用下列政策：
+ `[AmazonSageMakerFullAccess](https://console.aws.amazon.com/iam/home?#/policies/arn:aws:iam::aws:policy/AmazonSageMakerFullAccess)` — 使用此政策授予使用者或角色建立標籤工作的許可。這是廣泛的政策，授予實體使用 SageMaker AI 功能的許可，以及透過主控台和 API 提供必要 AWS 服務的功能。此政策授權予實體建立標籤工作，並使用 Amazon Cognito 建立和管理人力資源。如需進一步了解，請參閱 [AmazonSageMakerFullAccess 政策](https://docs.aws.amazon.com/sagemaker/latest/dg/security-iam-awsmanpol.html#security-iam-awsmanpol-AmazonSageMakerFullAccess)。
+ `[AmazonSageMakerGroundTruthExecution](https://console.aws.amazon.com/iam/home?#/policies/arn:aws:iam::aws:policy/AmazonSageMakerGroundTruthExecution)` — 若要建立一個*執行角色*，您可以將政策 `[AmazonSageMakerGroundTruthExecution](https://console.aws.amazon.com/iam/home?#/policies/arn:aws:iam::aws:policy/AmazonSageMakerGroundTruthExecution)` 附加至一名角色。執行角色是您在建立標籤工作時指定的角色，用於啟動標籤工作。此政策可讓您同時建立串流和非串流標籤工作，以及使用任何任務類型建立標籤工作。此受管政策有下列限制需要注意。
  + **Amazon S3 許可**：此政策授予執行角色 Amazon S3 儲存貯體的存取許可，其名稱中包含下列字串：`GroundTruth`、`Groundtruth`、`groundtruth`、`SageMaker`、`Sagemaker` 和 `sagemaker` 或名稱中包含 `SageMaker` (不區分大小寫) 的[物件標籤](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html)。請確定您的輸入和輸出儲存貯體名稱包含這些字串，或為執行角色新增其他許可，以[授予 Amazon S3 儲存貯體的存取許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_examples_s3_rw-bucket.html)。您必須授予此角色許可，才能在 Amazon S3 儲存貯體上執行下列動作：`AbortMultipartUpload`、`GetObject` 和 `PutObject`。
  + **自訂工作流程**：當您建立[自訂標記工作流程](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-custom-templates.html)時，此執行角色僅限於呼叫 AWS Lambda 具有下列其中一個字串的函數，做為函數名稱的一部分：`GtRecipe`、`sagemaker`、、 `SageMaker` `Sagemaker`或 `LabelingFunction`。這同時適用於註釋前和註釋後 Lambda 函式。如果您選擇使用不含這些字串的名稱，則必須為用來建立標籤工作的執行角色明確提供 `lambda:InvokeFunction` 許可。

若要了解如何將 AWS 受管政策連接至使用者或角色，請參閱《[IAM 使用者指南》中的新增和移除 IAM 身分許可](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html#add-policies-console)。

# 授予 IAM 許可以使用 Amazon SageMaker Ground Truth 主控台
<a name="sms-security-permission-console-access"></a>

若要使用 SageMaker AI 主控台的 Ground Truth 區域，您需要授予實體存取 SageMaker AI 和其他 Ground Truth 互動 AWS 服務的許可。存取其他 AWS 服務所需的許可取決於您的使用案例：
+ 所有使用案例都需要 Amazon S3 許可。這些許可必須包含輸入和輸出資料之 Amazon S3 儲存貯體的授予存取權。
+ AWS Marketplace 使用廠商人力資源需要 許可。
+ 私有工作團隊設定需要 Amazon Cognito 許可。
+ AWS KMS 需要 許可才能檢視可用於輸出資料加密的可用 AWS KMS 金鑰。
+ 如需列出預先存在的執行角色或建立新角色時，需要 IAM 許可。此外，您必須使用新增 `PassRole` 許可，來允許 SageMaker AI 使用選擇的執行角色來啟動標籤工作。

以下各節列出您可能想授予角色以使用 Ground Truth 的一個或多個功能之政策。

**Topics**
+ [Ground Truth 主控台許可](#sms-security-permissions-console-all)
+ [自訂標籤工作流程許可](#sms-security-permissions-custom-workflow)
+ [私有人力資源許可](#sms-security-permission-workforce-creation)
+ [廠商人力資源許可](#sms-security-permissions-workforce-creation-vendor)

## Ground Truth 主控台許可
<a name="sms-security-permissions-console-all"></a>

若要授予使用者或角色使用 SageMaker AI 主控台 Ground Truth 區域的許可，以建立標籤工作，請將下列政策附加至該使用者或角色。下列政策會授予 IAM 角色許可，使用[內建任務類型](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-task-types.html)任務類型建立標籤工作。如果您要建立自訂標籤工作流程，請將 [自訂標籤工作流程許可](#sms-security-permissions-custom-workflow) 中的政策新增至下列政策。下列政策中包含的每個 `Statement`，都在此程式碼區塊下方提供說明。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "SageMakerApis",
            "Effect": "Allow",
            "Action": [
                "sagemaker:*"
            ],
            "Resource": "*"
        },
        {
            "Sid": "KmsKeysForCreateForms",
            "Effect": "Allow",
            "Action": [
                "kms:DescribeKey",
                "kms:ListAliases"
            ],
            "Resource": "*"
        },
        {
            "Sid": "AccessAwsMarketplaceSubscriptions",
            "Effect": "Allow",
            "Action": [
                "aws-marketplace:ViewSubscriptions"
            ],
            "Resource": "*"
        },
        {
            "Sid": "SecretsManager",
            "Effect": "Allow",
            "Action": [
                "secretsmanager:CreateSecret",
                "secretsmanager:DescribeSecret",
                "secretsmanager:ListSecrets"
            ],
            "Resource": "*"
        },
        {
            "Sid": "ListAndCreateExecutionRoles",
            "Effect": "Allow",
            "Action": [
                "iam:ListRoles",
                "iam:CreateRole",
                "iam:CreatePolicy",
                "iam:AttachRolePolicy"
            ],
            "Resource": "*"
        },
        {
            "Sid": "PassRoleForExecutionRoles",
            "Effect": "Allow",
            "Action": [
                "iam:PassRole"
            ],
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "iam:PassedToService": "sagemaker.amazonaws.com"
                }
            }
        },
        {
            "Sid": "GroundTruthConsole",
            "Effect": "Allow",
            "Action": [
                "groundtruthlabeling:*",
                "lambda:InvokeFunction",
                "lambda:ListFunctions",
                "s3:GetObject",
                "s3:PutObject",
                "s3:ListBucket",
                "s3:GetBucketCors",
                "s3:PutBucketCors",
                "s3:ListAllMyBuckets",
                "cognito-idp:AdminAddUserToGroup",
                "cognito-idp:AdminCreateUser",
                "cognito-idp:AdminDeleteUser",
                "cognito-idp:AdminDisableUser",
                "cognito-idp:AdminEnableUser",
                "cognito-idp:AdminRemoveUserFromGroup",
                "cognito-idp:CreateGroup",
                "cognito-idp:CreateUserPool",
                "cognito-idp:CreateUserPoolClient",
                "cognito-idp:CreateUserPoolDomain",
                "cognito-idp:DescribeUserPool",
                "cognito-idp:DescribeUserPoolClient",
                "cognito-idp:ListGroups",
                "cognito-idp:ListIdentityProviders",
                "cognito-idp:ListUsers",
                "cognito-idp:ListUsersInGroup",
                "cognito-idp:ListUserPoolClients",
                "cognito-idp:ListUserPools",
                "cognito-idp:UpdateUserPool",
                "cognito-idp:UpdateUserPoolClient"
            ],
            "Resource": "*"
        }
    ]
}
```

------

此政策包含下列陳述式。您可以將特定資源新增至該陳述式的 `Resource` 清單，以限制任何這些陳述式的範圍。

`SageMakerApis`

此陳述式包含 `sagemaker:*`，可讓使用者執行所有 [SageMaker AI API 動作](sagemaker/latest/APIReference/API_Operations.html)。您可以禁止使用者執行非用於建立和監控標籤工作的動作，以限制此政策的範圍。

**`KmsKeysForCreateForms`**

只有在您想要授予使用者在 Ground Truth 主控台中列出和選取 AWS KMS 金鑰以用於輸出資料加密的許可時，才需要包含此陳述式。上述政策授予使用者列出和選擇 AWS KMS帳戶中任何密鑰的許可。若要限制使用者可以列出和選取的金鑰，請在 `Resource` 中指定這些金鑰 ARN。

**`SecretsManager`**

此陳述式提供使用者在建立標籤工作 AWS Secrets Manager 所需的 中描述、列出和建立資源的許可。

`ListAndCreateExecutionRoles`

此陳述式授予使用者許可，在您的帳戶中列出 (`ListRoles`) 和建立 (`CreateRole`) IAM 角色。它也會授予使用者許可，以建立 (`CreatePolicy`) 政策和附加 (`AttachRolePolicy`) 政策至實體。要在主控台中列出、選擇並建立一個執行角色，這些為必要項目。

如果您已經建立一個執行角色，並想要縮小此陳述式的範圍，以便使用者只能在主控台中選取該角色，請在 `Resource` 中指定您希望使用者有權查看的角色 ARN，並移除動作 `CreateRole`、`CreatePolicy` 和 `AttachRolePolicy`。

`AccessAwsMarketplaceSubscriptions`

建立標籤工作時，需要這些許可才能檢視和選擇您已訂閱的廠商工作團隊。要授予使用者*訂閱*廠商工作團隊的許可，請將 [廠商人力資源許可](#sms-security-permissions-workforce-creation-vendor) 中的陳述式新增到上面的政策中

`PassRoleForExecutionRoles`

為了授予標籤工作建立者預覽工作者使用者介面的許可，並驗證輸入資料、標籤和指示是否正確顯示，此為必要項目。此陳述式提供實體許可，可將用於建立標籤工作的 IAM 執行角色傳遞給 SageMaker AI，以轉譯和預覽工作者使用者介面。若要縮小此政策的範圍，請在 `Resource` 下方新增用來建立標籤工作之執行角色的角色 ARN。

**`GroundTruthConsole`**
+ `groundtruthlabeling` — 這允許使用者執行使用 Ground Truth 主控台某些功能所需的特定動作。其中包含描述標籤工作狀態的許可 (`DescribeConsoleJob`)，列出輸入資訊清單檔案中的所有資料集物件 (`ListDatasetObjects`)，篩選選取資料集取樣時的資料集 (`RunFilterOrSampleDatasetJob`)，以及在使用自動化資料標籤時，產生輸入資訊清單檔案 (`RunGenerateManifestByCrawlingJob`)。這些動作僅在使用 Ground Truth 主控台時可用，無法使用 API 直接呼叫。
+ `lambda:InvokeFunction` 和 `lambda:ListFunctions` — 這些動作會授予使用者許可，以列出和調用用於執行自訂標籤工作流程的 Lambda 函式。
+ `s3:*` — 此陳述式中包含的所有 Amazon S3 許可都用於檢視 Amazon S3 儲存貯體以進行[自動化資料設定](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-console-create-manifest-file.html) (`ListAllMyBuckets`)、存取 Amazon S3 中的輸入資料 (`ListBucket`,`GetObject`)、在 Amazon S3 中檢查並在需要時建立 CORS 政策 (`GetBucketCors` 和 `PutBucketCors`)，以及將標籤工作輸出檔案寫入 S3 (`PutObject`)。
+ `cognito-idp` — 這些許可用於使用 Amazon Cognito 建立、檢視和管理員工以及私有人力資源。若要進一步了解這些動作，請參閱 [Amazon Cognito API 參考資料](https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-reference.html)。

## 自訂標籤工作流程許可
<a name="sms-security-permissions-custom-workflow"></a>

將下列陳述式新增至類似於 [Ground Truth 主控台許可](#sms-security-permissions-console-all) 中的政策，以授予使用者在[建立自訂標籤工作流程](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-custom-templates.html)時，選取預先存在的註釋前和註釋後 Lambda 函式的權限。

```
{
    "Sid": "GroundTruthConsoleCustomWorkflow",
    "Effect": "Allow",
    "Action": [
        "lambda:InvokeFunction",
        "lambda:ListFunctions"
    ],
    "Resource": "*"
}
```

若要了解如何授予實體建立和測試註釋前和註釋後 Lambda 函式的許可，請參閱[使用 Lambda 與 Ground Truth 的必要許可](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-custom-templates-step3-lambda-permissions.html)。

## 私有人力資源許可
<a name="sms-security-permission-workforce-creation"></a>

新增至許可政策時，下列許可會授予使用 Amazon Cognito建立和管理私有人力資源和工作團隊的存取許可。使用 [OIDC IdP 人力資源](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-create-private-oidc.html#sms-workforce-create-private-oidc-next-steps)不需要這些許可。

```
{
    "Effect": "Allow",
    "Action": [
        "cognito-idp:AdminAddUserToGroup",
        "cognito-idp:AdminCreateUser",
        "cognito-idp:AdminDeleteUser",
        "cognito-idp:AdminDisableUser",
        "cognito-idp:AdminEnableUser",
        "cognito-idp:AdminRemoveUserFromGroup",
        "cognito-idp:CreateGroup",
        "cognito-idp:CreateUserPool",
        "cognito-idp:CreateUserPoolClient",
        "cognito-idp:CreateUserPoolDomain",
        "cognito-idp:DescribeUserPool",
        "cognito-idp:DescribeUserPoolClient",
        "cognito-idp:ListGroups",
        "cognito-idp:ListIdentityProviders",
        "cognito-idp:ListUsers",
        "cognito-idp:ListUsersInGroup",
        "cognito-idp:ListUserPoolClients",
        "cognito-idp:ListUserPools",
        "cognito-idp:UpdateUserPool",
        "cognito-idp:UpdateUserPoolClient"
        ],
    "Resource": "*"
}
```

若要進一步了解如何使用 Amazon Cognito 建立私有人力資源，請參閱[Amazon Cognito 人力資源](sms-workforce-private-use-cognito.md)。

## 廠商人力資源許可
<a name="sms-security-permissions-workforce-creation-vendor"></a>

您可以將下列陳述式新增至[授予 IAM 許可以使用 Amazon SageMaker Ground Truth 主控台](#sms-security-permission-console-access)中的政策，以授予實體訂閱[廠商人力資源](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-management-vendor.html)的許可。

```
{
    "Sid": "AccessAwsMarketplaceSubscriptions",
    "Effect": "Allow",
    "Action": [
        "aws-marketplace:Subscribe",
        "aws-marketplace:Unsubscribe",
        "aws-marketplace:ViewSubscriptions"
    ],
    "Resource": "*"
}
```

# 為 Ground Truth 標籤工作建立 SageMaker AI 執行角色
<a name="sms-security-permission-execution-role"></a>

設定標籤工作時，您需要提供*執行角色*，這是 SageMaker AI 授權假設啟動和執行標籤工作的角色。

此角色必須授予下列項目的 Ground Truth 存取許可：
+ Amazon S3 以擷取輸入資料，並將輸出資料寫入至 Amazon S3 儲存貯體。您可以透過提供儲存貯體 ARN，授予 IAM 角色存取整個儲存貯體的許可；或者，您也可以授予角色存取儲存貯體中特定資源的存取權。例如，儲存貯體的 ARN 看起來可能類似於 `arn:aws:s3:::amzn-s3-demo-bucket1`，且 Amazon S3 儲存貯體中資源的 ARN 看起來可能類似於 `arn:aws:s3:::amzn-s3-demo-bucket1/prefix/file-name.png`。若要將動作套用至 Amazon S3 儲存貯體中的所有資源，您可以使用萬用字元：`*`。例如 `arn:aws:s3:::amzn-s3-demo-bucket1/prefix/*`。如需更多資訊，請參閱 Amazon Simple Storage Service 使用者指南中的 [Amazon S3 資源](https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html)。
+ CloudWatch 用來記錄工作者指標和標籤工作狀態。
+ AWS KMS 用於資料加密。(選用)
+ AWS Lambda 用於在建立自訂工作流程時處理輸入和輸出資料。

此外，如果您建立[串流標籤工作](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html)，則此角色必須具有存取許可：
+ Amazon SQS 可建立與用於[管理標籤請求](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-streaming-labeling-job.html#sms-streaming-how-it-works-sqs)的 SQS 佇列互動。
+ Amazon SNS 以從您的 Amazon SNS 輸入主題訂閱和擷取訊息，並將傳送訊息到您的 Amazon SNS 輸出主題。

所有這些許可都可以透過 `[AmazonSageMakerGroundTruthExecution](https://console.aws.amazon.com/iam/home?#/policies/arn:aws:iam::aws:policy/AmazonSageMakerGroundTruthExecution)` 受管政策進行授權，而*例外*情形如下：
+ Amazon S3 儲存貯體的資料和儲存磁碟區加密。若要了解如何設定這些許可，請參閱[使用 加密輸出資料和儲存磁碟區 AWS KMS](sms-security-kms-permissions.md)。
+ 選取及調用函式名稱中不包含 `GtRecipe`、`SageMaker`、`Sagemaker`、`sagemaker`、或 `LabelingFunction` 的 Lambda 函式之權限。
+ Amazon S3 儲存貯體的字首或儲存貯體名稱不包含 `GroundTruth`、`Groundtruth`、`groundtruth`、`SageMaker`、`Sagemaker` 和 `sagemaker`，或是[物件標籤](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html)名稱中包含 `SageMaker` (不區分大小寫)。

如果您需要比 `AmazonSageMakerGroundTruthExecution` 更為精細的許可，請使用下列政策範例，建立符合您特定使用案例的執行角色。

**Topics**
+ [內建任務類型 (非串流) 執行角色需求](#sms-security-permission-execution-role-built-in-tt)
+ [內建任務類型 (串流) 執行角色需求](#sms-security-permission-execution-role-built-in-tt-streaming)
+ [自訂任務類型的執行角色需求](#sms-security-permission-execution-role-custom-tt)
+ [自動化資料標籤權限需求](#sms-security-permission-execution-role-custom-auto-labeling)

## 內建任務類型 (非串流) 執行角色需求
<a name="sms-security-permission-execution-role-built-in-tt"></a>

下列政策將為[內建任務類型](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-task-types.html)授權建立標籤工作。此執行政策不包含 AWS KMS 資料加密或解密的許可。使用您自己的 Amazon S3 ARN 取代每個紅色斜體的 ARN。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "S3ViewBuckets",
            "Effect": "Allow",
            "Action": [
                "s3:ListBucket",
                "s3:GetBucketLocation"
            ],
            "Resource": [
                "arn:aws:s3:::<input-bucket-name>",
                "arn:aws:s3:::<output-bucket-name>"
            ]
        },
        {
            "Sid": "S3GetPutObjects",
            "Effect": "Allow",
            "Action": [
                "s3:AbortMultipartUpload",
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::<input-bucket-name>/*",
                "arn:aws:s3:::<output-bucket-name>/*"
            ]
        },
        {
            "Sid": "CloudWatch",
            "Effect": "Allow",
            "Action": [
                "cloudwatch:PutMetricData",
                "logs:CreateLogStream",
                "logs:CreateLogGroup",
                "logs:DescribeLogStreams",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        }
    ]
}
```

------

## 內建任務類型 (串流) 執行角色需求
<a name="sms-security-permission-execution-role-built-in-tt-streaming"></a>

如果您建立串流標籤工作，則必須將類似下列內容的政策，新增至用於建立標籤工作的執行角色。若要縮小政策的範圍，請將 `*`中的 取代`Resource`為您想要授予 IAM 角色存取和使用許可的特定 AWS 資源。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:AbortMultipartUpload",
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket/*",
                "arn:aws:s3:::amzn-s3-demo-bucket2/*"
            ]
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetObject"
            ],
            "Resource": "*",
            "Condition": {
                "StringEqualsIgnoreCase": {
                    "s3:ExistingObjectTag/SageMaker": "true"
                }
            }
        },
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetBucketLocation",
                "s3:ListBucket"
            ],
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket",
                "arn:aws:s3:::amzn-s3-demo-bucket2"
            ]
        },
        {
            "Sid": "CloudWatch",
            "Effect": "Allow",
            "Action": [
                "cloudwatch:PutMetricData",
                "logs:CreateLogStream",
                "logs:CreateLogGroup",
                "logs:DescribeLogStreams",
                "logs:PutLogEvents"
            ],
            "Resource": "*"
        },
        {
            "Sid": "StreamingQueue",
            "Effect": "Allow",
            "Action": [
                "sqs:CreateQueue",
                "sqs:DeleteMessage",
                "sqs:GetQueueAttributes",
                "sqs:GetQueueUrl",
                "sqs:ReceiveMessage",
                "sqs:SendMessage",
                "sqs:SetQueueAttributes"
            ],
            "Resource": "arn:aws:sqs:*:*:*GroundTruth*"
        },
        {
            "Sid": "StreamingTopicSubscribe",
            "Effect": "Allow",
            "Action": "sns:Subscribe",
            "Resource": [
                "arn:aws:sns:us-east-1:111122223333:input-topic-name",
                "arn:aws:sns:us-east-1:111122223333:output-topic-name"
            ],
            "Condition": {
                "StringEquals": {
                    "sns:Protocol": "sqs"
                },
                "StringLike": {
                    "sns:Endpoint": "arn:aws:sns:us-east-1:111122223333:*GroundTruth*"
                }
            }
        },
        {
            "Sid": "StreamingTopic",
            "Effect": "Allow",
            "Action": [
                "sns:Publish"
            ],
            "Resource": [
                "arn:aws:sns:us-east-1:111122223333:input-topic-name",
                "arn:aws:sns:us-east-1:111122223333:output-topic-name"
            ]
        },
        {
            "Sid": "StreamingTopicUnsubscribe",
            "Effect": "Allow",
            "Action": [
                "sns:Unsubscribe"
            ],
            "Resource": [
                "arn:aws:sns:us-east-1:111122223333:input-topic-name",
                "arn:aws:sns:us-east-1:111122223333:output-topic-name"
            ]
        }
    ]
}
```

------

## 自訂任務類型的執行角色需求
<a name="sms-security-permission-execution-role-custom-tt"></a>

如果您要建立[自訂標籤工作流程](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-custom-templates.html)，請將下列陳述式新增至執行角色政策，如同在 [內建任務類型 (非串流) 執行角色需求](#sms-security-permission-execution-role-built-in-tt) 或 [內建任務類型 (串流) 執行角色需求](#sms-security-permission-execution-role-built-in-tt-streaming) 中找到的執行角色政策。

此政策將執行角色授予 `Invoke` 您註釋前和註釋後 Lambda 函式的權限。

```
{
    "Sid": "LambdaFunctions",
    "Effect": "Allow",
    "Action": [
        "lambda:InvokeFunction"
    ],
    "Resource": [
        "arn:aws:lambda:<region>:<account-id>:function:<pre-annotation-lambda-name>",
        "arn:aws:lambda:<region>:<account-id>:function:<post-annotation-lambda-name>"
    ]
}
```

## 自動化資料標籤權限需求
<a name="sms-security-permission-execution-role-custom-auto-labeling"></a>

如果要在啟用[自動化資料標籤](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-automated-labeling.html)的情況下建立標籤工作，則必須 1) 新增一個政策，附加到執行角色的 IAM 政策，然後 2) 更新執行角色的信任政策。

下列陳述式允許將 IAM 執行角色傳遞給 SageMaker AI，以便分別用於執行用於主動學習和自動化資料標籤的訓練和推論任務。將此陳述式新增至執行角色政策，就像在 [內建任務類型 (非串流) 執行角色需求](#sms-security-permission-execution-role-built-in-tt) 或 [內建任務類型 (串流) 執行角色需求](#sms-security-permission-execution-role-built-in-tt-streaming) 中找到的執行角色政策。將 `arn:aws:iam::<account-number>:role/<role-name>` 取代為執行角色 ARN。您可以在 IAM 主控台的**角色**底下，找到您的 IAM 角色 ARN。

```
{
    "Effect": "Allow",
    "Action": [
        "iam:PassRole"
    ],
    "Resource": "arn:aws:iam::<account-number>:role/<execution-role-name>",
    "Condition": {
        "StringEquals": {
            "iam:PassedToService": [
                "sagemaker.amazonaws.com"
            ]
        }
    }
}
```

下列陳述式可讓 SageMaker AI 擔任執行角色，以建立和管理 SageMaker 訓練和推論任務。此政策必須新增至執行角色的信任關係。若要了解如何新增或修改 IAM 角色信任政策，請參閱 IAM 使用者指南中的[修改角色](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_modify.html)。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": {
        "Effect": "Allow",
        "Principal": {"Service": "sagemaker.amazonaws.com" },
        "Action": "sts:AssumeRole"
    }
}
```

------



# 使用 加密輸出資料和儲存磁碟區 AWS KMS
<a name="sms-security-kms-permissions"></a>

您可以在建立標籤工作時指定[客戶受管金鑰](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#master_keys)，以使用 AWS Key Management Service (AWS KMS) 加密來自標籤工作的輸出資料。如果您使用 API 作業 `CreateLabelingJob` 建立使用自動化資料標籤的標籤工作，您也可以使用客戶受管金鑰來加密連接至機器學習 (ML) 運算執行個體的儲存磁碟區，以執行訓練和推論工作。

本節說明您必須附加至客戶受管金鑰以啟用輸出資料加密的 IAM 政策，以及必須附加至客戶受管金鑰和執行角色的政策，以使用儲存磁碟區加密。若要進一步了解這些選項，請參閱[輸出資料與儲存磁碟區加密](sms-security.md)。

## 使用 KMS 加密輸出資料
<a name="sms-security-kms-permissions-output-data"></a>

如果您指定 AWS KMS 客戶受管金鑰來加密輸出資料，則必須將類似以下內容的 IAM 政策新增至該金鑰。此政策提供您用來建立標籤工作權限的 IAM 執行角色，以便使用此金鑰執行 `"Action"` 中列出的所有動作。若要進一步了解這些動作，請參閱《 AWS Key Management Service 開發人員指南》中的[AWS KMS 許可](https://docs.aws.amazon.com/kms/latest/developerguide/kms-api-permissions-reference.html)。

要使用此政策，請將 `"Principal"` 的 IAM 服務角色 ARN，取代為您用來建立標籤工作的執行角色 ARN。在主控台中建立標籤工作時，這是您在**工作概觀**區段下為 **IAM 角色**指定的角色。使用 `CreateLabelingJob` 建立標籤工作時，這是您為 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html#sagemaker-CreateLabelingJob-request-RoleArn](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html#sagemaker-CreateLabelingJob-request-RoleArn) 指定的 ARN。

```
{
    "Sid": "AllowUseOfKmsKey",
    "Effect": "Allow",
    "Principal": {
        "AWS": "arn:aws:iam::111122223333:role/service-role/example-role"
    },
    "Action": [
        "kms:Encrypt",
        "kms:Decrypt",
        "kms:ReEncrypt*",
        "kms:GenerateDataKey*",
        "kms:DescribeKey"
    ],
    "Resource": "*"
}
```

## 加密自動化資料標籤機器學習 (ML) 運算執行個體儲存磁碟區
<a name="sms-security-kms-permissions-storage-volume"></a>

如果您指定一個 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_LabelingJobResourceConfig.html#sagemaker-Type-LabelingJobResourceConfig-VolumeKmsKeyId](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_LabelingJobResourceConfig.html#sagemaker-Type-LabelingJobResourceConfig-VolumeKmsKeyId)，用來加密機器學習 (ML) 運算執行個體的儲存磁碟區，其用於自動化資料標籤訓練和推論，則必須執行下列動作：
+ 將 [使用 KMS 加密輸出資料](#sms-security-kms-permissions-output-data) 中描述的許可附加至客戶受管金鑰。
+ 將類似下列內容的政策，附加至您用來建立標籤工作的 IAM 執行角色。這是您在 `CreateLabelingJob` 中為 [https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html#sagemaker-CreateLabelingJob-request-RoleArn](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html#sagemaker-CreateLabelingJob-request-RoleArn) 指定的 IAM 角色。若要進一步了解此政策允許`"kms:CreateGrant"`的動作，請參閱 AWS Key Management Service API 參考[https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateGrant.html](https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateGrant.html)中的 。

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

****  

```
{
"Version":"2012-10-17",		 	 	  
"Statement": 
 [  
   {
    "Effect": "Allow",
    "Action": [
       "kms:CreateGrant"
    ],
    "Resource": "*"
  }
]
}
```

------

若要進一步了解 Ground Truth 儲存磁碟區加密，請參閱[使用 KMS 金鑰加密自動化資料標籤儲存磁碟區 (僅限 API)](sms-security.md#sms-security-kms-storage-volume)。