

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

# Ground Truth 安全性和权限
<a name="sms-security-general"></a>

可以使用该页面上的主题来了解 Ground Truth 安全功能，以及如何配置 AWS Identity and Access Management (IAM) 权限以允许用户或角色创建标注作业。此外，了解如何创建*执行角色*。执行角色是您在创建标注作业时指定的角色。此角色用于启动标注作业。

如果您是新用户并希望快速入门，或者不需要细粒度权限，请参阅[在 Ground Truth 中使用 IAM 托管策略](sms-security-permissions-get-started.md)。

有关 IAM 用户和角色的更多信息，请参阅《IAM 用户指南》中的[身份（用户、组和角色）](https://docs.aws.amazon.com/IAM/latest/UserGuide/id.html)。

要了解有关将 IAM 与 A SageMaker I 结合使用的更多信息，请参阅[AWS Identity and Access Management 适用于亚马逊 A SageMaker I](security-iam.md)。

**Topics**
+ [

# 输入映像数据的 CORS 要求
](sms-cors-update.md)
+ [

# 分配 IAM 权限以使用 Ground Truth
](sms-security-permission.md)
+ [

# 在亚马逊虚拟私有云中使用 Amazon G SageMaker round Truth
](sms-vpc.md)
+ [

# 输出数据和存储卷加密
](sms-security.md)
+ [

# 人力身份验证和限制
](sms-security-workforce-authentication.md)

# 输入映像数据的 CORS 要求
<a name="sms-cors-update"></a>

2020 年初，Chrome 和 Firefox 等广泛使用的浏览器改变了基于图像元数据（称为 [EXIF 数据](https://en.wikipedia.org/wiki/Exif)）旋转图像的默认行为。以前，浏览器总是按照图像在磁盘上的存储方式显示图像，通常是不旋转的。改变后，图像现在根据一段称为*方向值*的图像元数据进行旋转。这对整个机器学习 (ML) 界都有重要影响。例如，如果对图像进行注释的应用程序不考虑 EXIF 方向，则它们可能会以意外的方向显示图像，从而导致标签不正确。

从 Chrome 89 开始， AWS 无法再自动阻止图像的旋转，因为网络标准组织 W3C 已认定，控制图像旋转的功能违反了网络的同源政策。因此，为了确保在您提交创建标注作业的请求时，人工以可预测的方向对您的输入图像进行注释，您必须将 CORS 头策略添加到包含输入图像的 Amazon S3 存储桶中。

**重要**  
如果没有将 CORS 配置添加到包含输入数据的 Amazon S3 存储桶中，那么这些输入数据对象的标注任务将失败。

如果您通过 Ground Truth 控制台创建作业，默认情况下 CORS 处于启用状态。如果所有输入数据与输入清单文件*不*位于同一个 Amazon S3 存储桶中，则必须使用以下说明为包含输入数据的所有 Amazon S3 存储桶添加 CORS 配置。

如果使用 `CreateLabelingJob` API 创建 Ground Truth 标注作业，可以在 S3 控制台中为包含输入数据的 Amazon S3 存储桶添加 CORS 策略。要在 Amazon S3 控制台上对包含输入图像的 Amazon S3 存储桶设置所需的 CORS 头，请按照[如何使用 CORS 添加跨域资源共享？](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-cors-configuration.html)中的详细说明进行操作。对存放图像的存储桶使用以下 CORS 配置代码。如果使用 Amazon S3 控制台将策略添加到存储桶，则必须使用 JSON 格式。

**重要**  
如果创建 3D 点云或视频帧标注作业，则必须在 CORS 配置中添加附加规则。要了解更多信息，请分别参阅[3D 点云标注作业权限要求](sms-security-permission-3d-point-cloud.md)和[视频帧作业权限要求](sms-video-overview.md#sms-security-permission-video-frame)。

**JSON**

```
[{
   "AllowedHeaders": [],
   "AllowedMethods": ["GET"],
   "AllowedOrigins": ["*"],
   "ExposeHeaders": ["Access-Control-Allow-Origin"]
}]
```

**XML**

```
<CORSConfiguration>
 <CORSRule>
   <AllowedOrigin>*</AllowedOrigin>
   <AllowedMethod>GET</AllowedMethod>
   <ExposeHeader>Access-Control-Allow-Origin</ExposeHeader>
 </CORSRule>
</CORSConfiguration>
```

下面的 GIF 演示了 Amazon S3 文档中使用 Amazon S3 控制台添加 CORS 头策略的说明。有关书面说明，请参阅《Amazon Simple Storage Service 用户指南》中的文档页面[如何使用 CORS 添加跨域资源共享？](https://docs.aws.amazon.com/AmazonS3/latest/user-guide/add-cors-configuration.html)上的**使用 Amazon S3 控制台**。

![\[关于如何使用 Amazon S3 管理控制台添加 CORS 标头策略的图片。\]](http://docs.aws.amazon.com/zh_cn/sagemaker/latest/dg/images/sms/gifs/cors-config.gif)


# 分配 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)。

# 在亚马逊虚拟私有云中使用 Amazon G SageMaker round Truth
<a name="sms-vpc"></a>

 借助 [Amazon Virtual Private Cloud](https://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/VPC_Introduction.html)（Amazon VPC），您可以在您定义的逻辑隔离的虚拟网络中启动 AWS 资源。Ground Truth 支持在 Amazon VPC 内运行标注作业，而无需通过互联网连接。当您在亚马逊 VPC 中启动标签任务时，您的 VPC 和 Ground Truth 之间的通信将在 AWS 网络内完全安全地进行。

本指南介绍如何通过以下方式在 Amazon VPC 中使用 Ground Truth：

1. [在亚马逊虚拟私有云中运行 Amazon G SageMaker round Truth 标签工作](samurai-vpc-labeling-job.md)

1. [在私有工作人员门户中使用 Amazon VPC 模式](samurai-vpc-worker-portal.md)

# 在亚马逊虚拟私有云中运行 Amazon G SageMaker round Truth 标签工作
<a name="samurai-vpc-labeling-job"></a>

Ground Truth 支持 Amazon VPC 中的以下功能。
+ 您可以使用 Amazon S3 存储桶策略来控制从特定的 Amazon VPC 终端节点或特定 VPCs终端节点访问存储桶。如果您启动了标注作业，而输入数据位于 Amazon S3 存储桶中，且该存储桶仅限 VPC 中的用户使用，那么您可以添加一个存储桶策略，同时授予 Ground Truth 端点访问存储桶的权限。要了解更多信息，请参阅[允许 Ground Truth 访问受 VPC 限制的 Amazon S3 存储库](#sms-vpc-permissions-s3)。
+ 您可以在 VPC 中启动[自动数据标注作业](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-automated-labeling.html)。您可以使用 VPC 配置来指定 VPC 子网和安全组。 SageMaker AI 使用此配置在您的 VPC 中启动用于自动数据标签的训练和推理作业。要了解更多信息，请参阅[在 VPC 中创建自动数据标注作业](#sms-vpc-permissions-automated-labeling)。

您可以通过以下任何一种方式使用这些选项。
+ 您可以使用这两种方法，使用受 VPC 保护并启用了自动数据标注功能的 Amazon S3 存储桶启动标注作业。
+ 您可以使用受 VPC 保护的存储桶，通过任何[内置任务类型](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-task-types.html)启动标注作业。
+ 您可以使用受 VPC 保护的存储桶启动[自定义标注工作流](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-custom-templates.html)。Ground Truth 使用 [AWS PrivateLink](https://docs.aws.amazon.com/vpc/latest/privatelink/endpoint-services-overview.html) 端点与注释前和注释后 Lambda 函数进行交互。

在 Amazon VPC 中创建标注作业之前，我们建议您查看[在 VPC 中运行 Ground Truth 标注作业的先决条件](#sms-vpc-gt-prereq)。

## 在 VPC 中运行 Ground Truth 标注作业的先决条件
<a name="sms-vpc-gt-prereq"></a>

在 Amazon VPC 中创建 Ground Truth 标注作业之前，请查看以下先决条件。
+ 如果您是 Ground Truth 的新用户，请查看[入门](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-getting-started.html)以了解如何创建标注作业。
+ 如果输入数据位于受 VPC 保护的 Amazon S3 存储桶中，则工作人员必须从 VPC 访问工作人员门户。基于 VPC 的标注作业需要使用私人工作团队。要了解有关创建私有工作团队的更多信息，请参阅[使用私有人力](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-private.html)。
+ 以下是在 VPC 中启动标注作业的特定先决条件。
  + 使用[创建 Amazon S3 VPC 端点](https://docs.aws.amazon.com/sagemaker/latest/dg/train-vpc.html#train-vpc-s3)中的说明。自动数据标注工作流中使用的训练和推理容器使用此端点与 Amazon S3 中的存储桶进行通信。
  + 要了解有关此功能的更多信息，请查看[自动数据标注](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-automated-labeling.html)。请注意，以下[内置任务类型](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-task-types.html)支持自动数据标注：[图像分类（单标签）](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-image-classification.html)、[图像语义分割](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-semantic-segmentation.html)、[边界框](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-bounding-box.html)和[文本分类（单标签）](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-text-classification.html)。流式标注作业不支持自动数据标注。
+ 查看 [Ground Truth 安全性和权限](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-security-general.html)部分，确保您已满足以下条件。
  + 创建标注作业的用户拥有所有必要的权限
  + 您已创建具有所需权限的 IAM 执行角色。如果您的使用案例不需要经过微调的权限，我们建议您使用[授予开始使用 Ground Truth 的一般权限](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-security-permission.html#sms-security-permissions-get-started)中所述的 IAM 托管策略。
  + 允许您的 VPC 访问 `sagemaker-labeling-data-region` 和 `sm-bxcb-region-saved-task-states` S3 存储桶。这些是系统拥有的区域化 S3 存储桶，当工作人员处理任务时，可以从工作人员门户访问这些存储桶。我们使用这些存储桶与系统托管的数据进行交互。

## 允许 Ground Truth 访问受 VPC 限制的 Amazon S3 存储库
<a name="sms-vpc-permissions-s3"></a>

以下各节将详细介绍 Ground Truth 使用 Amazon S3 存储桶启动标注作业所需的权限，这些存储桶的访问权限仅限于您的 VPC 和 VPC 端点。要了解如何限制 VPC 对 Amazon S3 存储桶的访问，请参阅《Amazon Simple Storage Service 用户指南》指南中的[使用存储桶策略控制 VPC 端点的访问](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies-vpc-endpoint.html)。要了解如何将策略添加到 S3 存储桶，请参阅[使用 Amazon S3 控制台添加存储桶策略](https://docs.aws.amazon.com/AmazonS3/latest/userguide/add-bucket-policy.html)。

**注意**  
修改现有存储桶上的策略会导致 `IN_PROGRESS` Ground Truth 作业失败。我们建议您使用新的存储桶启动新作业。如果您想继续使用同一个存储桶，可以执行以下操作之一。  
等待 `IN_PROGRESS` 作业完成。
使用控制台或 AWS CLI终止作业。

您可以使用 [AWS PrivateLink](https://aws.amazon.com/privatelink/) 端点限制 VPC 中的用户访问 Amazon S3 存储桶。例如，以下 S3 存储桶策略只允许从 `<bucket-name>` 和端点 `<vpc>` 访问特定存储桶 `<vpc-endpoint>`。修改此策略时，必须将全部*red-italized text*替换为您的资源和规格。

**注意**  
以下策略*拒绝* VPC 内用户*除外*的所有实体执行 `Action` 中列出的操作。如果您未在此列表中包含操作，则任何有权访问此数据桶并有权执行这些操作的实体仍可访问这些操作。例如，如果用户有权对 Amazon S3 存储桶执行 `GetBucketLocation`，则下面的策略不会限制用户在 VPC 外部执行此操作。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Id": "Policy1415115909152",
    "Statement": [
        {
            "Sid": "AccessToSpecificVPCEOnly",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Effect": "Deny",
            "Resource": [
                "arn:aws:s3:::amzn-s3-demo-bucket",
                "arn:aws:s3:::amzn-s3-demo-bucket/*"
            ],
            "Condition": {
                "StringNotEquals": {
                    "aws:sourceVpce": [
                        "vpce-12345678",
                        "vpce-12345678901234567"
                    ]
                }
            }
        }
    ]
}
```

------

Ground Truth 必须能够对用于配置标注作业的 S3 存储桶执行以下 Amazon S3 操作。

```
"s3:AbortMultipartUpload",
"s3:GetObject",
"s3:PutObject",
"s3:ListBucket",
"s3:GetBucketLocation"
```

您可以通过在存储桶策略中添加 Ground Truth 端点来做到这一点，就像前面提到的那样。下表包括每个 AWS 区域的 Ground Truth 服务终端节点。将您用于运行标注作业的同一 [AWS 区域](https://docs.aws.amazon.com/general/latest/gr/rande.html)的端点添加到存储桶策略中。


****  

| AWS 区域 | Ground Truth 端点 | 
| --- | --- | 
| us-east-2 | vpce-02569ba1c40aad0bc | 
| us-east-1 | vpce-08408e335ebf95b40 | 
| us-west-2 | vpce-0ea07aa498eb78469 | 
| ca-central-1 | vpce-0d46ea4c9ff55e1b7 | 
| eu-central-1 | vpce-0865e7194a099183d | 
| eu-west-2 | vpce-0bccd56798f4c5df0 | 
| eu-west-1 | vpce-0788e7ed8628e595d | 
| ap-south-1 | vpce-0d7fcda14e1783f11 | 
| ap-southeast-2 | vpce-0b7609e6f305a77d4 | 
| ap-southeast-1 | vpce-0e7e67b32e9efed27 | 
| ap-northeast-2 | vpce-007893f89e05f2bbf | 
| ap-northeast-1 | vpce-0247996a1a1807dbd | 

例如，以下策略限制对以下项执行 `GetObject` 和 `PutObject` 操作：
+ 向 VPC (`<vpc>`) 中的用户提供的 Amazon S3 存储桶
+ VPC 端点 (`<vpc-endpoint>`)
+ Ground Truth 服务端点 (`<ground-truth-endpoint>`)

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Id": "1",
    "Statement": [
        {
            "Sid": "DenyAccessFromNonGTandCustomerVPC",
            "Effect": "Deny",
            "Principal": "*",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::bucket-name",
                "arn:aws:s3:::bucket-name/*"
            ],
            "Condition": {
              "StringNotEquals": {
                "aws:SourceVpc": "vpc-12345678",
                "aws:sourceVpce": [
                  "vpce-12345678",
                  "vpce-12345678"
                ] 
             }
           }
        }
    ]
}
```

------

如果您希望用户有权使用 Ground Truth 控制台启动标注作业，则还必须使用 `aws:PrincipalArn` 条件将用户的 ARN 添加到存储桶策略中。此用户还必须有权对您用于启动标注作业的存储桶执行以下 Amazon S3 操作。

```
"s3:GetObject",
"s3:PutObject",
"s3:ListBucket",
"s3:GetBucketCors",
"s3:PutBucketCors",
"s3:ListAllMyBuckets",
```

以下代码是存储桶策略的示例，该策略只允许以下项对 S3 存储桶 `<bucket-name>` 执行 `Action` 中列出的操作。
+ *<role-name>*
+ `aws:sourceVpce` 中列出的 VPC 端点
+ VPC 中的用户名为 *<vpc>*

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Id": "1",
    "Statement": [
        {
            "Sid": "DenyAccessFromNonGTandCustomerVPC",
            "Effect": "Deny",
            "Principal": "*",
            "Action": [
                "s3:GetObject",
                "s3:PutObject"
            ],
            "Resource": [
                "arn:aws:s3:::bucket-name/*",
                "arn:aws:s3:::bucket-name"
            ],
            "Condition": {
                "StringNotEquals": {
                    "aws:SourceVpc": "vpc-12345678",
                    "aws:PrincipalArn": "arn:aws:iam::111122223333:role/role-name"
                },
                "StringNotEquals": {
                    "aws:sourceVpce": [
                        "vpce-12345678",
                        "vpce-12345678"
                    ]
                }
            }
        }
    ]
}
```

------

**注意**  
用于输入和输出数据的 Amazon VPC 接口终端节点和受保护的 Amazon S3 存储桶必须位于您用于创建标签任务的同一 AWS 区域。

授予 Ground Truth 访问 Amazon S3 存储桶的权限后，可以使用[创建标注作业](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-create-labeling-job.html)中的任一主题来启动标注作业。为输入和输出数据存储桶指定受 VPC 限制的 Amazon S3 存储桶。

## 在 VPC 中创建自动数据标注作业
<a name="sms-vpc-permissions-automated-labeling"></a>

要使用 Amazon VPC 创建自动数据标注作业，您需要使用 Ground Truth 控制台或 `CreateLabelingJob` API 操作提供 VPC 配置。 SageMaker AI 使用您提供的子网和安全组启动用于自动标记的训练和推理作业。

**重要**  
在使用 VPC 配置启动自动数据标注作业之前，请确保已使用要用于标注作业的 VPC 创建了 Amazon S3 VPC 端点。要了解如何操作，请参阅[创建 Amazon S3 VPC 端点](https://docs.aws.amazon.com/sagemaker/latest/dg/train-vpc.html#train-vpc-s3)。  
此外，如果使用受 VPC 限制的 Amazon S3 存储桶创建自动数据标注作业，则必须按照[允许 Ground Truth 访问受 VPC 限制的 Amazon S3 存储库](#sms-vpc-permissions-s3)中的说明授予 Ground Truth 访问存储桶的权限。

使用以下过程学习如何向标注作业请求中添加 VPC 配置。

**将 VPC 配置添加到自动数据标注作业（控制台）：**

1. 按照[创建标注作业（控制台）](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-create-labeling-job-console.html)中的说明，完成该过程中的每个步骤，直至步骤 15。

1. 在**工作人员**部分中，选中**启用自动数据标注**旁边的复选框。

1. 选择箭头，最大化控制台的 **VPC 配置**部分。

1. 指定要用于自动数据标注作业的**虚拟私有云 (VPC)**。

1. 选择**子网**下的下拉列表并选择一个或多个子网。

1. 选择**安全组**下的下拉列表并选择一个或多个组。

1. 完成[创建标注作业（控制台）](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-create-labeling-job-console.html)过程的所有剩余步骤。

**将 VPC 配置添加到自动数据标注作业 (API)：**  
要使用 Ground Truth API 操作 `CreateLabelingJob` 配置标注作业，请按照[创建自动数据标注作业 (API)](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-automated-labeling.html#sms-create-automated-labeling-api) 中的说明配置您的请求。除了本文档中描述的参数外，还必须在 `LabelingJobResourceConfig` 中包含一个 `VpcConfig` 参数，以便使用以下架构指定一个或多个子网和安全组。

```
"LabelingJobAlgorithmsConfig": { 
      "InitialActiveLearningModelArn": "string",
      "LabelingJobAlgorithmSpecificationArn": "string",
      "LabelingJobResourceConfig": { 
         "VolumeKmsKeyId": "string",
         "VpcConfig": { 
            "SecurityGroupIds": [ "string" ],
            "Subnets": [ "string" ]
         }
      }
}
```

以下是一个 [AWS Python SDK (Boto3) 请求](https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/sagemaker.html#SageMaker.Client.create_labeling_job)示例，该请求使用私有人力在美国东部（弗吉尼亚州北部）区域中创建自动数据标注作业。将所有内容*red-italicized text*替换为您的标签作业资源和规格。要了解有关该`CreateLabelingJob`操作的更多信息，请参阅[创建标注任务 (API)](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-create-labeling-job-api.html) 教程和 [CreateLabelingJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateLabelingJob.html)API 文档。

```
import boto3
client = boto3.client(service_name='sagemaker')

response = client.create_labeling_job(
    LabelingJobName="example-labeling-job",
    LabelAttributeName="label",
    InputConfig={
        'DataSource': {
            'S3DataSource': {
                'ManifestS3Uri': "s3://bucket/path/manifest-with-input-data.json"
            }
        }
    },
    "LabelingJobAlgorithmsConfig": {
      "LabelingJobAlgorithmSpecificationArn": "arn:aws:sagemaker:us-east-1:027400017018:labeling-job-algorithm-specification/tasktype",
      "LabelingJobResourceConfig": { 
         "VpcConfig": { 
            "SecurityGroupIds": [ "sg-01233456789", "sg-987654321" ],
            "Subnets": [ "subnet-e0123456", "subnet-e7891011" ]
         }
      }
    },
    OutputConfig={
        'S3OutputPath': "s3://bucket/path/file-to-store-output-data",
        'KmsKeyId': "string"
    },
    RoleArn="arn:aws:iam::*:role/*,
    LabelCategoryConfigS3Uri="s3://bucket/path/label-categories.json",
    StoppingConditions={
        'MaxHumanLabeledObjectCount': 123,
        'MaxPercentageOfInputDatasetLabeled': 123
    },
    HumanTaskConfig={
        'WorkteamArn': "arn:aws:sagemaker:region:*:workteam/private-crowd/*",
        'UiConfig': {
            'UiTemplateS3Uri': "s3://bucket/path/custom-worker-task-template.html"
        },
        'PreHumanTaskLambdaArn': "arn:aws:lambda:us-east-1:432418664414:function:PRE-tasktype",
        'TaskKeywords': [
            "Images",
            "Classification",
            "Multi-label"
        ],
        'TaskTitle': "Add task title here",
        'TaskDescription': "Add description of task here for workers",
        'NumberOfHumanWorkersPerDataObject': 1,
        'TaskTimeLimitInSeconds': 3600,
        'TaskAvailabilityLifetimeInSeconds': 21600,
        'MaxConcurrentTaskCount': 1000,
        'AnnotationConsolidationConfig': {
            'AnnotationConsolidationLambdaArn': "arn:aws:lambda:us-east-1:432418664414:function:ACS-tasktype"
        },
    Tags=[
        {
            'Key': "string",
            'Value': "string"
        },
    ]
)
```

# 在私有工作人员门户中使用 Amazon VPC 模式
<a name="samurai-vpc-worker-portal"></a>

要限制在 Amazon VPC 内工作的标注者可以访问工作人员门户，可以在创建 Ground Truth 私有人力时添加 VPC 配置。您还可以向现有的私有人力添加 VPC 配置。Ground Truth 会自动在 VPC 中创建 VPC 接口端点，并在 VPC 端点和 Ground Truth 服务之间设置 AWS PrivateLink 。可从 VPC 访问与人力相关联的工作人员门户 URL。在对公共互联网设置限制之前，也可以从公共互联网访问工作人员门户 URL。删除人力或从人力中删除 VPC 配置时，Ground Truth 会自动删除与人力相关联的 VPC 端点。

**注意**  
一个人力只能支持一个 VPC。

[点云](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-point-cloud.html)和[视频](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-video.html)任务不支持通过 VPC 加载。

本指南演示了如何完成在人力中添加和删除 Amazon VPC 配置的必要步骤，并满足先决条件。

## 先决条件
<a name="samurai-vpc-getting-started-prerequisites"></a>

要在 Amazon VPC 中运行 Ground Truth 标注作业，请查看以下先决条件。
+ 您已经配置了可以使用的 Amazon VPC。如果您尚未配置 VPC，请按照[创建 VPC](https://docs.aws.amazon.com/vpc/latest/privatelink/create-interface-endpoint.html#interface-endpoint-shared-subnets) 的相关说明操作。
+ 根据[工作人员任务模板](https://docs.aws.amazon.com/sagemaker/latest/dg/a2i-instructions-overview.html)的编写方式，可以在标注任务期间直接从 Amazon S3 访问存储在 Amazon S3 存储桶中的标注数据。在这些情况下，必须对 VPC 网络进行配置，以允许从人工标注者使用的设备向包含标注数据的 S3 存储桶传输流量。
+ 按照[查看和更新 VPC 的 DNS 属性](https://docs.aws.amazon.com/vpc/latest/userguide/vpc-dns.html#vpc-dns-updating)中的说明，为 VPC 启用 DNS 主机名和 DNS 解析。

**注意**  
可以通过两种方法为人力配置 VPC。您可以通过[控制台](https://console.aws.amazon.com/sagemaker)或 AWS SageMaker A [I CLI](https://aws.amazon.com/cli/) 执行此操作。

# 使用 A SageMaker I 控制台管理 VPC 配置
<a name="samurai-vpc-workforce-console"></a>

您可以使用 [SageMaker AI 控制台](https://console.aws.amazon.com/sagemaker)添加或删除 VPC 配置。您还可以删除现有人力。

## 为人力添加 VPC 配置
<a name="samurai-add-vpc-workforce"></a>

### 创建私有人力
<a name="samurai-vpc-create-workforce"></a>
+ [使用 Amazon Cognito 创建私有人力](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-private-use-cognito.html)
+ [使用 OpenID Connect (OIDC) 身份提供者 (IdP) 创建私有人力](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-private-use-oidc.html)。

创建私有人力后，向其添加 VPC 配置。

1. 在您的主机中导航至 [Amazon SageMaker Runtim](https://console.aws.amazon.com/sagemaker) e。

1. 在左侧面板中选择**标注人力**。

1. 选择**私有**以访问您的私有人力。**人力状态**变为**活动**后，选择 **VPC** 旁边的**添加**。

1. 当系统提示您配置 VPC 时，请提供以下信息：

   1. 您的 **VPC**

   1. **子网**

      1. 确保您的 VPC 已有子网

   1. **安全组**

      1. 
**注意**  
选择的安全组不能超过 5 个。

   1. 填写此信息后，选择**确认**。

1. 选择**确认**后，您将重定向回**标注人力**下的**私有**页面。您应该会在顶部看到一个绿色横幅，上面显示**使用 VPC 配置的私有人力更新已成功初始化**。人力状态为**正在更新**。**删除人力**按钮旁边是**刷新**按钮，可用于检索最新的**人力状态**。人力状态更改为**活动**后，VPC 端点 ID 也会更新。

## 从人力中删除 VPC 配置
<a name="samurai-remove-vpc-workforce"></a>

使用以下信息，通过控制台从人力中删除 VPC 配置。

1. 在您的主机中导航至 [Amazon SageMaker Runtim](https://console.aws.amazon.com/sagemaker) e。

1. 在左侧面板中选择**标注人力**。

1. 查找并选择您的人力。

1. 在**私有人力摘要**下，找到 **VPC**，然后选择其旁边的**删除**。

1. 选择**删除**。

## 通过控制台删除人力
<a name="samurai-delete-vpc-workforce"></a>

如果删除一个人力，就不应该再有任何与之相关的团队。只有当人力状态为**活动**或**失败**时，才能删除人力。

使用以下信息通过控制台删除人力。

1. 在您的主机中导航至 [Amazon SageMaker Runtim](https://console.aws.amazon.com/sagemaker) e。

1. 在左侧面板中选择**标注人力**。

1. 查找并选择您的人力。

1. 选择**删除人力**。

1. 选择**删除**。

# 使用 SageMaker AI AWS API 管理 VPC 配置
<a name="samurai-vpc-workforce-cli"></a>

使用以下各节来详细了解如何管理 VPCs 配置，同时保持对工作团队的适当访问权限。

## 使用 VPC 配置创建人力
<a name="samurai-create-vpc-cli"></a>

如果账户中已经有一个人力，则必须先删除它。您还可以使用 VPC 配置更新人力。

```
aws sagemaker create-workforce --cognito-config '{"ClientId": "app-client-id","UserPool": "Pool_ID",}' --workforce-vpc-config \       
" {\"VpcId\": \"vpc-id\", \"SecurityGroupIds\": [\"sg-0123456789abcdef0\"], \"Subnets\": [\"subnet-0123456789abcdef0\"]}" --workforce-name workforce-name
{
    "WorkforceArn": "arn:aws:sagemaker:us-west-2:xxxxxxxxx:workforce/workforce-name"
}
```

描述人力并确保其状态为 `Initializing`。

```
aws sagemaker describe-workforce --workforce-name workforce-name
{
    "Workforce": {
        "WorkforceName": "workforce-name",
        "WorkforceArn": "arn:aws:sagemaker:us-west-2:xxxxxxxxx:workforce/workforce-name",
        "LastUpdatedDate": 1622151252.451,
        "SourceIpConfig": {
            "Cidrs": []
        },
        "SubDomain": "subdomain.us-west-2.sagamaker.aws.com",
        "CognitoConfig": {
            "UserPool": "Pool_ID",
            "ClientId": "app-client-id"
        },
        "CreateDate": 1622151252.451,
        "WorkforceVpcConfig": {
            "VpcId": "vpc-id",
            "SecurityGroupIds": [
                "sg-0123456789abcdef0"
            ],
            "Subnets": [
                "subnet-0123456789abcdef0"
            ]
        },
        "Status": "Initializing"
    }
}
```

导航到 Amazon VPC 控制台。从左侧面板中选择**端点**。您的账户中应该创建了两个 VPC 端点。

## 为人力添加 VPC 配置
<a name="samurai-add-vpc-cli"></a>

使用以下命令用 VPC 配置更新非 VPC 私有人力。

```
aws sagemaker update-workforce --workforce-name workforce-name\
--workforce-vpc-config "{\"VpcId\": \"vpc-id\", \"SecurityGroupIds\": [\"sg-0123456789abcdef0\"], \"Subnets\": [\"subnet-0123456789abcdef0\"]}"
```

描述人力并确保其状态为 `Updating`。

```
aws sagemaker describe-workforce --workforce-name workforce-name
{
    "Workforce": {
        "WorkforceName": "workforce-name",
        "WorkforceArn": "arn:aws:sagemaker:us-west-2:xxxxxxxxx:workforce/workforce-name",
        "LastUpdatedDate": 1622151252.451,
        "SourceIpConfig": {
            "Cidrs": []
        },
        "SubDomain": "subdomain.us-west-2.sagamaker.aws.com",
        "CognitoConfig": {
            "UserPool": "Pool_ID",
            "ClientId": "app-client-id"
        },
        "CreateDate": 1622151252.451,
        "WorkforceVpcConfig": {
            "VpcId": "vpc-id",
            "SecurityGroupIds": [
                "sg-0123456789abcdef0"
            ],
            "Subnets": [
                "subnet-0123456789abcdef0"
            ]
        },
        "Status": "Updating"
    }
}
```

导航到 Amazon VPC 控制台。从左侧面板中选择**端点**。您的账户中应该创建了两个 VPC 端点。

## 从人力中删除 VPC 配置
<a name="samurai-remove-vpc-cli"></a>

用空 VPC 配置更新 VPC 私有人力以删除 VPC 资源。

```
aws sagemaker update-workforce --workforce-name workforce-name\ 
--workforce-vpc-config "{}"
```

描述人力并确保其状态为 `Updating`。

```
aws sagemaker describe-workforce --workforce-name workforce-name
{
    "Workforce": {
        "WorkforceName": "workforce-name",
        "WorkforceArn": "arn:aws:sagemaker:us-west-2:xxxxxxxxx:workforce/workforce-name",
        "LastUpdatedDate": 1622151252.451,
        "SourceIpConfig": {
            "Cidrs": []
        },
        "SubDomain": "subdomain.us-west-2.sagamaker.aws.com",
        "CognitoConfig": {
            "UserPool": "Pool_ID",
            "ClientId": "app-client-id"
        },
        "CreateDate": 1622151252.451,
        "Status": "Updating"
    }
}
```

导航至 Amazon VPC 控制台。从左侧面板中选择**端点**。应删除两个 VPC 端点。

## 在通过 VPC 保持访问的同时，限制公众访问工作人员门户
<a name="public-access-vpc"></a>

 VPC 或非 VPC 工作人员门户中的工作人员可以看到分配给他们的标注作业任务。任务来自于通过 OIDC 组分配工作团队中的工作人员。客户有责任通过在人力中设置 `sourceIpConfig` 来限制其公共工作人员门户的访问权限。

**注意**  
您只能通过 SageMaker API 限制对工作人员门户的访问。这无法通过控制台完成。

使用以下命令限制公众访问工作人员门户。

```
aws sagemaker update-workforce --region us-west-2 \
--workforce-name workforce-demo --source-ip-config '{"Cidrs":["10.0.0.0/16"]}'
```

在人力上设置 `sourceIpConfig` 后，工作人员可以访问 VPC 中的工作人员门户，但不能通过公共互联网访问。

**注意**  
您无法为 VPC 中的工作人员门户设置 `sourceIP` 限制。

# 输出数据和存储卷加密
<a name="sms-security"></a>

借助 Amazon G SageMaker round Truth，您可以标记高度敏感的数据，控制自己的数据，并采用安全最佳实践。在标注作业运行时，Ground Truth 会对传输中数据和静态数据进行加密。此外，你可以使用 AWS Key Management Service (AWS KMS) 和 Ground Truth 来执行以下操作：
+ 使用[客户托管密钥](https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#master_keys)对输出数据进行加密。
+ 在自动数据标签作业中使用 AWS KMS 客户托管密钥，对附加到用于模型训练和推理的计算实例的存储卷进行加密。

使用本页上的主题了解有关这些 Ground Truth 安全功能的更多信息。

## 使用 KMS 密钥加密输出数据
<a name="sms-security-kms-output-data"></a>

或者，您可以在创建标签任务时提供 AWS KMS 客户托管密钥，Ground Truth 使用该密钥来加密您的输出数据。

如果您不提供客户托管密钥，Amazon A SageMaker I 会使用您角色账户 AWS 托管式密钥 的 Amazon S3 默认密钥来加密您的输出数据。

如果您提供了客户托管密钥，则必须向[使用加密输出数据和存储卷 AWS KMS](sms-security-kms-permissions.md)中所述的密钥添加所需的权限。当您使用 API 操作 `CreateLabelingJob` 时，可以使用参数 `[KmsKeyId](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_LabelingJobOutputConfig.html#sagemaker-Type-LabelingJobOutputConfig-KmsKeyId)` 指定客户托管密钥 ID。请参阅以下过程，了解如何在使用控制台创建标注作业时添加客户托管密钥。

**要添加 AWS KMS 密钥以加密输出数据（控制台），请执行以下操作：**

1. 完成[创建标注作业（控制台）](sms-create-labeling-job-console.md)中的前 7 个步骤。

1. 在步骤 8 中，选择**其他配置**旁边的箭头以展开此部分。

1. 在**加密密 AWS KMS 钥**中，选择要用于加密输出数据的密钥。

1. 完成[创建标注作业（控制台）](sms-create-labeling-job-console.md)中的其余步骤来创建标注作业。

## 使用 KMS 密钥加密自动数据标注存储卷（仅限 API）
<a name="sms-security-kms-storage-volume"></a>

使用 `CreateLabelingJob` API 操作创建带有自动数据标注功能的标注作业时，可以选择加密附加到运行训练和推理作业的 ML 计算实例的存储卷。要向存储卷添加加密，请使用参数`VolumeKmsKeyId`输入 AWS KMS 客户托管密钥。有关该参数的更多信息，请参阅 `[LabelingJobResourceConfig](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_LabelingJobResourceConfig.html#sagemaker-Type-LabelingJobResourceConfig-VolumeKmsKeyId)`。

如果您为指定密钥 ID 或 ARN`VolumeKmsKeyId`，则您的 SageMaker AI 执行角色必须包含调用权限。`kms:CreateGrant`要了解如何将该权限添加到执行角色中，请参阅[为 Ground Truth 标签作业创建 SageMaker AI 执行角色](sms-security-permission-execution-role.md)。

**注意**  
如果您在控制台中创建标签任务时指定了 AWS KMS 客户托管密钥，则该密钥*仅*用于加密您的输出数据。该密钥不用于加密附加到用于自动数据标注的 ML 计算实例的存储卷。

# 人力身份验证和限制
<a name="sms-security-workforce-authentication"></a>

Ground Truth 允许您使用自己的私有人力来处理标注作业。*私有人力*是一个抽象概念，是指为您工作的一群人。每个标注作业是使用工作团队（包含人力中的工作人员）创建的。Ground Truth 支持使用 Amazon Cognito 创建私有人力。

Ground Truth 人力映射到 Amazon Cognito 用户池。Ground Truth 工作团队映射到 Amazon Cognito 用户组。Amazon Cognito 管理工作人员身份验证。Amazon Cognito 支持 Open ID connection (OIDC)，客户可以使用自己的身份提供者 (IdP) 设置 Amazon Cognito 联合身份验证。

Ground Truth 每个 AWS 地区每个账户只允许一名员工。每个人力具有专用的 Ground Truth 工作门户登录 URL。

您也可以将工作人员限制在无类域间路由 (CIDR) block/IP 地址范围内。这意味着，注释者必须位于特定的网络才能访问注释站点。您最多可以为一个人力添加 10 个 CIDR 块。要了解更多信息，请参阅[使用 Amazon SageMaker API 进行私人劳动力管理](sms-workforce-management-private-api.md)。

要了解如何创建私有人力，请参阅[创建私有人力 (Amazon Cognito)](sms-workforce-create-private.md)。

## 限制对人力类型的访问
<a name="sms-security-permission-condition-keys"></a>

Amazon G SageMaker round Truth 的工作团队分为三种[劳动力类型](https://docs.aws.amazon.com/sagemaker/latest/dg/sms-workforce-management.html)之一：公共（使用 Amazon Mechanical Turk）、私人和供应商。要使用其中一种类型或工作团队 ARN 限制用户访问特定工作团队，请使用`sagemaker:WorkteamArn`条件`sagemaker:WorkteamType` and/or 键。对于 `sagemaker:WorkteamType` 条件键，请使用[字符串条件运算符](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_String)。对于 `sagemaker:WorkteamArn` 条件键，请使用 [Amazon 资源名称 (ARN) 条件运算符](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition_operators.html#Conditions_ARN)。如果用户尝试使用受限的工作团队创建标签作业， SageMaker AI 会返回拒绝访问错误。

以下策略演示了将 `sagemaker:WorkteamType` 和 `sagemaker:WorkteamArn` 条件键与适当的条件运算符和有效条件值结合使用的不同方法。

以下示例使用 `sagemaker:WorkteamType` 条件键和 `StringEquals` 条件运算符一起限制对公有工作团队的访问。它接受以下格式的条件值：`workforcetype-crowd`，其中*workforcetype*可以等于`public``private`、或`vendor`。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RestrictWorkteamType",
            "Effect": "Deny",
            "Action": "sagemaker:CreateLabelingJob",
            "Resource": "*",
            "Condition": {
                "StringEquals": {
                    "sagemaker:WorkteamType": "public-crowd"
                }
            }
        }
    ]
}
```

------

以下策略演示如何使用 `sagemaker:WorkteamArn` 条件键限制对公有工作团队的访问。第一个策略演示如何将该条件键与工作团队 ARN 的 IAM 有效正则表达式变量和 `ArnLike` 条件运算符一起使用。第二个策略演示如何将该条件键与 `ArnEquals` 条件运算符和工作团队 ARN 一起使用。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RestrictWorkteamType",
            "Effect": "Deny",
            "Action": "sagemaker:CreateLabelingJob",
            "Resource": "*",
            "Condition": {
                "ArnLike": {
                    "sagemaker:WorkteamArn": "arn:aws:sagemaker:*:*:workteam/public-crowd/*"
                }
            }
        }
    ]
}
```

------

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "RestrictWorkteamType",
            "Effect": "Deny",
            "Action": "sagemaker:CreateLabelingJob",
            "Resource": "*",
            "Condition": {
                "ArnEquals": {
                    "sagemaker:WorkteamArn": "arn:aws:sagemaker:us-west-2:394669845002:workteam/public-crowd/default"
                }
            }
        }
    ]
}
```

------