

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 分配 IAM 权限以使用 Ground Truth
<a name="sms-security-permission"></a>

使用本节中的主题来学习如何使用 AWS Identity and Access Management (IAM) 托管策略和自定义策略来管理对 Ground Truth 和相关资源的访问权限。

您可以使用此页面上的各部分了解以下内容：
+ 如何创建向用户或角色授予创建标注作业的权限的 IAM 策略。管理员可以使用 IAM 策略来限制对 Amazon A SageMaker I 和其他特定于 Ground Truth 的 AWS 服务的访问。
+ 如何创建 A SageMaker I *执行角色*。执行角色是您在创建标注作业时指定的角色。该角色用于启动和管理标注作业。

以下是本页面的主题概述：
+ 如果您刚开始使用 Ground Truth，或者您的使用案例不需要细粒度权限，则建议您使用[在 Ground Truth 中使用 IAM 托管策略](sms-security-permissions-get-started.md)中所述的 IAM 托管策略。
+ 在[授予 IAM 使用亚马逊 G SageMaker round 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)` – 使用此策略向用户或角色授予创建标注作业的权限。这是一项广泛的政策，它授予实体通过控制台和 AP SageMaker I 使用人工智能功能以及必要 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 权限**：此策略向执行角色授予访问名称中包含 `GroundTruth`、`Groundtruth`、`groundtruth`、`SageMaker`、`Sagemaker` 和 `sagemaker` 字符串的 Amazon S3 存储桶或具有[对象标签](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html)（在名称中包括 `SageMaker`，不区分大小写）的存储桶的权限。确保您的输入和输出存储桶名称包含这些字符串，或为您的执行角色添加额外权限，以[授予访问 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 使用亚马逊 G SageMaker round Truth 控制台的权限
<a name="sms-security-permission-console-access"></a>

要使用 SageMaker 人工智能控制台的 Ground Truth 区域，你需要向实体授予访问 SageMaker 人工智能和其他与 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中列出和选择账户中任何密钥的权限。要限制用户可以列出和选择的密钥，请在 ARNs 中指定这些密钥`Resource`。

**`SecretsManager`**

此语句允许用户描述、列出和创建创建标注任务 AWS Secrets Manager 所需的资源。

`ListAndCreateExecutionRoles`

此语句向用户授予在账户中列出 (`ListRoles`) 和创建 (`CreateRole`) IAM 角色的权限。此语句还向用户授予创建 (`CreatePolicy`) 策略和将 (`AttachRolePolicy`) 策略附加到实体的权限。需要这些权限才能在控制台中列出、选择并在必要时创建执行角色。

如果您已经创建了执行角色，并且想要缩小此语句的范围，以便用户只能在控制台中选择该 ARNs 角色，请指定您希望用户有权查看的角色`Resource`并移除操作`CreateRole``CreatePolicy`、和`AttachRolePolicy`。

`AccessAwsMarketplaceSubscriptions`

需要这些权限才能查看和选择您在创建标注作业时已订阅的供应商工作团队。要向用户授予*订阅*供应商工作团队的权限，请将 [供应商人力权限](#sms-security-permissions-workforce-creation-vendor) 中的语句添加到上面的策略中。

`PassRoleForExecutionRoles`

这是为标注作业创建者提供预览工作人员 UI 和验证输入数据、标签和说明是否正确显示的权限所必需的。此语句允许实体将用于创建标签作业的 IAM 执行角色传递给 A SageMaker I 以呈现和预览工作器界面。要缩小此策略的范围，请在 `Resource` 下添加用于创建标注作业的执行角色的角色 ARN。

**`GroundTruthConsole`**
+ `groundtruthlabeling` – 这允许用户执行使用 Ground Truth 控制台的某些功能所需的操作。这些权限包括描述标注作业状态 (`DescribeConsoleJob`)、列出输入清单文件中的所有数据集对象 (`ListDatasetObjects`)、在选择数据集采样时筛选数据集 (`RunFilterOrSampleDatasetJob`)，以及在使用自动数据标注时生成输入清单文件 (`RunGenerateManifestByCrawlingJob`)。这些操作只有在使用 Ground Truth 控制台时才可用，不能直接使用 API 调用。
+ `lambda:InvokeFunction` 和 `lambda:ListFunctions` – 这些操作向用户授予列出和调用用于运行自定义标注工作流的 Lambda 函数的权限。
+ `s3:*` – 此语句中包含的所有 Amazon S3 权限用于查看[自动数据设置](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-console-create-manifest-file.html)所用的 Amazon S3 存储桶 (`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 函数的权限，请参阅[在 Ground Truth 中使用 Lambda 所需的权限](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 Workforces](sms-workforce-private-use-cognito.md)。

## 供应商人力权限
<a name="sms-security-permissions-workforce-creation-vendor"></a>

您可以将以下语句添加到[授予 IAM 使用亚马逊 G SageMaker round 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 函数的权限。
+ 前缀或存储桶名称中不包括 `GroundTruth`、`Groundtruth`、`groundtruth`、`SageMaker`、`Sagemaker` 和 `sagemaker` 的 Amazon S3 存储桶，或名称中包括 `SageMaker` 的[对象标签](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html)（不区分大小写）。

如果您需要比 `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。 ARNs

------
#### [ 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 执行角色传递给 A SageMaker I，以便其可用于运行分别用于主动学习和自动数据标签的训练和推理作业。将此语句添加到执行角色策略中，如 [内置任务类型（非流式）执行角色要求](#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)。