

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

# 使用 Studio 进行可信身份传播
<a name="trustedidentitypropagation"></a>

可信身份传播是一项 AWS IAM Identity Center 功能，互联 AWS 服务的管理员可以使用该功能来授予和审核对服务数据的访问权限。对这些数据的访问权限基于用户属性，例如组关联。设置可信身份传播需要互联 AWS 服务的管理员和 IAM Identity Center 管理员之间的协作。有关更多信息，请参阅[先决条件和注意事项](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overall-prerequisites.html)。

Amazon SageMaker Studio 和 IAM 身份中心管理员可以合作连接服务以实现可信身份传播。可信身份传播通过简化以下操作来满足企业跨 AWS 服务的身份验证需求：
+ 增强审计，用于跟踪特定用户的操作
+ 通过与兼容 AWS 服务集成，管理数据科学和机器学习工作负载的访问权限
+ 受监管行业的合规要求

Studio 支持可信身份传播以进行审计，并支持通过互联 AWS 服务进行访问控制。Studio 中的可信身份传播不会直接处理其内部的身份验证或授权决策。相反，此功能会将身份上下文信息传播到可兼容的服务，这些服务可使用这些信息进行访问控制。

当您在 Studio 中使用可信身份传播时，您的 IAM Identity Center 身份会传播到连接的 AWS 服务，从而创建更精细的权限和安全治理。

**Topics**
+ [可信身份传播架构和兼容性](trustedidentitypropagation-compatibility.md)
+ [为 Studio 设置可信身份传播](trustedidentitypropagation-setup.md)
+ [监控和审计 CloudTrail](trustedidentitypropagation-auditing.md)
+ [用户后台会话](trustedidentitypropagation-user-background-sessions.md)
+ [如何在启用了可信身份传播的情况下与其他 AWS 服务连接](trustedidentitypropagation-connect-other.md)

# 可信身份传播架构和兼容性
<a name="trustedidentitypropagation-compatibility"></a>

可信身份传播 AWS IAM Identity Center 与 Amazon SageMaker Studio 和其他关联 AWS 服务集成，可跨服务传播用户的身份上下文。下一页总结了可信身份传播架构以及与 SageMaker AI 的兼容性。有关可信身份传播工作原理的全面概述 AWS，请参阅[可信身份传播概述](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overview.html)。

可信身份传播架构的关键组件包括：
+ **可信身份传播**：一种在应用程序和服务之间传播用户身份上下文的方法
+ **身份上下文**：有关用户的信息
+ **身份增强型 IAM 角色会话**：身份增强型角色会话添加了身份上下文，该上下文将用户标识符传递给它所 AWS 调用的服务
+ **互联 AWS 服务**：可以识别通过可信身份传播传播传播的身份上下文的其他 AWS 服务

可信身份传播允许互联 AWS 服务根据用户的身份做出访问决策。在 Studio 内部，IAM 角色用作身份上下文的载体，而不是用于做出访问控制决策。身份上下文会传播到连接的 AWS 服务，在这些服务中，它既可以用于访问控制，也可以用于审计目的。有关更多信息，请参阅[可信身份传播注意事项](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overall-prerequisites.html#trustedidentitypropagation-considerations)。

当您使用 Studio 启用可信身份传播并通过 IAM 身份中心进行身份验证时，A SageMaker I：
+ 从 IAM Identity Center 捕获用户身份上下文
+ 创建包含用户身份上下文的身份增强型 IAM 角色会话
+ 当用户访问资源时，将身份增强型 IAM 角色会话传递给兼容的 AWS 服务
+ 使下游 AWS 服务能够根据用户身份做出访问决策和记录活动

## 兼容的 SageMaker AI 功能
<a name="trustedidentitypropagation-compatibility-compatible-features"></a>

可信身份传播可与以下 Studio 功能结合使用：
+ [Amazon SageMaker Studio](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-updated-launch.html) 私有空间（JupyterLab 以及基于代码操作系统的代码编辑器、Visual Studio 代码——开源）

**注意**  
当 Studio 启动并启用可信身份传播时，它不仅会使用您的执行角色权限，还会使用您的身份上下文。但是，在实例设置期间，以下流程将仅使用执行角色权限，而不使用身份上下文：生命周期配置 Bring-Your-Own-Image、用于用户日志转发的 CloudWatch 代理。
可信身份传播目前不支持[远程访问](https://docs.aws.amazon.com/sagemaker/latest/dg/remote-access.html)。
当您在 Studio 笔记本中使用代入角色操作时，代入的角色不会传播可信身份传播上下文。只有原始执行角色才能维护身份上下文。
+  [SageMaker训练](https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-training.html) 
+  [SageMaker正在处理](https://docs.aws.amazon.com/sagemaker/latest/dg/processing-job.html) 
+  [SageMaker AI 实时托管](https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-options.html) 
+  [SageMaker管道](https://docs.aws.amazon.com/sagemaker/latest/dg/pipelines-overview.html) 
+  [SageMaker实时推理](https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints.html) 
+  [SageMaker异步推理](https://docs.aws.amazon.com/sagemaker/latest/dg/async-inference.html) 
+  [托管式 MLflow](https://docs.aws.amazon.com/sagemaker/latest/dg/mlflow.html) 

## 兼容的 AWS 服务
<a name="trustedidentitypropagation-compatibility-compatible-services"></a>

Amazon SageMaker Studio 的可信身份传播与兼容 AWS 服务集成，其中启用了可信身份传播。有关如何启用可信身份传播的示例的完整列表，请参阅[使用案例](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-integrations.html)。与可信身份传播兼容的服务如下所示。
+  [Amazon Athena](https://docs.aws.amazon.com/athena/latest/ug/workgroups-identity-center.html) 
+  [EC2 上的 Amazon EMR](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-idc-start.html) 
+  [EMR Serverless](https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/security-iam-service-trusted-prop.html) 
+  [AWS Lake Formation](https://docs.aws.amazon.com/lake-formation/latest/dg/identity-center-integration.html) 
+  [Amazon Redshift Data API](https://docs.aws.amazon.com/redshift/latest/mgmt/data-api-trusted-identity-propagation.html) 
+ Amazon S3（通过 [Amazon S3 访问权限管控](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants-get-started.html)）
+ [AWS Glue 连接](https://docs.aws.amazon.com/glue/latest/dg/security-trusted-identity-propagation.html)

当通过 SageMaker AI 启用可信身份传播时，启用了可信身份传播的彼此 AWS 服务就会相互连接。这些服务连接后，会识别并使用用户身份上下文来进行访问控制和审计。

## 支持的 AWS 区域
<a name="trustedidentitypropagation-compatibility-supported-regions"></a>

在[支持 IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/regions.html) 且支持使用 IAM Identity Center 身份验证的 Studio 的环境中，Studio 支持可信身份传播。Studio 支持以下方面的可信身份传播 AWS 区域：
+ af-south-1
+ ap-east-1
+ ap-northeast-1
+ ap-northeast-2
+ ap-northeast-3
+ ap-south-1
+ ap-southeast-1
+ ap-southeast-2
+ ap-southeast-3
+ ca-central-1
+ eu-central-1
+ eu-central-2
+ eu-north-1
+ eu-south-1
+ eu-west-1
+ eu-west-2
+ eu-west-3
+ il-central-1
+ me-south-1
+ sa-east-1
+ us-east-1
+ us-east-2
+ us-west-1
+ us-west-2

# 为 Studio 设置可信身份传播
<a name="trustedidentitypropagation-setup"></a>

为 Amazon SageMaker Studio 设置可信身份传播需要您的 Amazon A SageMaker I 域配置 IAM 身份中心身份验证方法。此部分将指导您完成为 Studio 用户启用和配置可信身份传播所需的先决条件和步骤。

**Topics**
+ [先决条件](#trustedidentitypropagation-setup-prerequisites)
+ [为您的 Amazon A SageMaker I 域启用可信身份传播](#trustedidentitypropagation-setup-enable)
+ [配置你的 SageMaker AI 执行角色](#trustedidentitypropagation-setup-permissions)

## 先决条件
<a name="trustedidentitypropagation-setup-prerequisites"></a>

在为 SageMaker AI 设置可信身份传播之前，请按照以下说明设置您的 IAM 身份中心。

**注意**  
确保 IAM Identity Center 和域位于同一区域。
+  [IAM Identity Center 可信身份传播先决条件](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overall-prerequisites.html#trustedidentitypropagation-prerequisites) 
+  [设置 IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/getting-started.html) 
+  [将用户添加到 IAM Identity Center 目录](https://docs.aws.amazon.com/singlesignon/latest/userguide/addusers.html) 

## 为您的 Amazon A SageMaker I 域启用可信身份传播
<a name="trustedidentitypropagation-setup-enable"></a>

**重要**  
您只能为已配置 AWS IAM Identity Center 身份验证方法的域启用可信身份传播。
您的 IAM 身份中心和 SageMaker Amazon AI 域名必须相同 AWS 区域。

通过下列选项之一来了解如何为新域或现有域启用可信身份传播。

------
#### [ New domain - console ]

**使用 SageMaker AI 控制台为新域启用可信身份传播**

1. 打开[亚马逊 A SageMaker I 控制台](https://console.aws.amazon.com/sagemaker)。

1. 导航到**域**。

1. [创建自定义域](https://docs.aws.amazon.com/sagemaker/latest/dg/onboard-custom.html)。该域必须已配置 **AWS IAM Identity Center** 身份验证方法。

1. 在**可信身份传播**部分，选择**为该域上的所有用户启用可信身份传播**。

1. 完成自定义创建过程。

------
#### [ Existing domain - console ]

**使用 SageMaker AI 控制台为现有域启用可信身份传播**
**注意**  
为了在为现有域启用可信身份传播后正常运行，用户需要重新启动其现有的 IAM Identity Center 会话。要做到这一点，可以：  
用户需要注销并重新登录其现有的 IAM 身份中心会话
管理员可以[结束员工用户的活动会话](https://docs.aws.amazon.com/singlesignon/latest/userguide/end-active-sessions.html)。

1. 打开[亚马逊 A SageMaker I 控制台](https://console.aws.amazon.com/sagemaker)。

1. 导航到**域**。

1. 选择现有域。该域必须已配置 **AWS IAM Identity Center** 身份验证方法。

1. 在**域设置**选项卡中，选择**身份验证和权限**部分中的**编辑**。

1. 选择**为该域上的所有用户启用可信身份传播**。

1. 完成域配置。

------
#### [ Existing domain - AWS CLI ]

使用为现有域启用可信身份传播 AWS CLI

**注意**  
为了在为现有域启用可信身份传播后正常运行，用户需要重新启动其现有的 IAM Identity Center 会话。要做到这一点，可以：  
用户需要注销并重新登录其现有的 IAM 身份中心会话
管理员可以[结束员工用户的活动会话](https://docs.aws.amazon.com/singlesignon/latest/userguide/end-active-sessions.html)。

```
aws sagemaker update-domain \
    --region $REGION \
    --domain-id $DOMAIN_ID \
    --domain-settings "TrustedIdentityPropagationSettings={Status=ENABLED}"
```
+ `DOMAIN_ID`是亚马逊 A SageMaker I 域名 ID。有关更多信息，请参阅[查看域](https://docs.aws.amazon.com/sagemaker/latest/dg/domain-view.html)。
+ `REGION`是你 AWS 区域 的 Amazon A SageMaker I 域名。你可以在任何 AWS 主机页面的右上角找到它。

------

## 配置你的 SageMaker AI 执行角色
<a name="trustedidentitypropagation-setup-permissions"></a>

要为 Studio 用户启用可信身份传播，所有可信身份传播角色都需要设置以下上下文权限。更新所有角色的信任策略以包含 `sts:AssumeRole` 和 `sts:SetContext` 操作。[更新角色信任策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_update-role-trust-policy.html)时，请使用以下策略。

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

****  

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

------

# 监控和审计 CloudTrail
<a name="trustedidentitypropagation-auditing"></a>

启用可信身份传播后， AWS CloudTrail 日志将包含执行操作的特定用户的身份信息，而不仅仅是 IAM 角色。这将提供增强型审计功能以实现合规性和安全性。

要查看 CloudTrail 日志中的身份信息，请执行以下操作：
+ 打开 [CloudTrail 控制台](https://console.aws.amazon.com/cloudtrail)。
+ 从左侧导航窗格中选择**事件历史记录**。
+ 从 SageMaker AI 和相关服务中选择事件。
+ 在**事件记录**下，查找 `onBehalfOf` 密钥。这包含可映射到特定的 IAM Identity Center 用户的 `userId` 密钥和其他用户标识信息。

  有关更多信息[，请参阅 IAM 身份中心的CloudTrail 用例](https://docs.aws.amazon.com/singlesignon/latest/userguide/sso-cloudtrail-use-cases.html)。

# 用户后台会话
<a name="trustedidentitypropagation-user-background-sessions"></a>

即使用户不再处于活动状态，用户后台会话也会继续运行。这些会话支持在用户注销后仍可继续运行的长时间作业。这可以通过 SageMaker 人工智能的可信身份传播来实现。以下页面说明了用户后台会话的配置选项和行为。

**注意**  
启用可信身份传播后，现有的活动用户会话不会受到影响。默认持续时间仅适用于新用户会话或重新启动的会话。
用户后台会话适用于任何长时间运行的 SageMaker AI 工作流程或具有持续状态的作业。这包括但不限于维持执行状态或需要持续监控的任何 SageMaker AI 资源。例如， SageMaker 训练、处理和管道执行作业。

**Topics**
+ [配置用户后台会话](#configure-user-background-sessions)
+ [默认用户后台会话持续时间](#default-user-background-session-duration)
+ [在 Studio 中禁用可信身份传播的影响](#user-background-session-impact-disable-trustedidentitypropagation-studio)
+ [在 IAM Identity Center 控制台中禁用用户后台会话的影响](#user-background-session-impact-disable-trustedidentitypropagation-identity-center)
+ [运行时系统注意事项](#user-background-session-runtime-considerations)

## 配置用户后台会话
<a name="configure-user-background-sessions"></a>

启用 Amazon SageMaker Studio 的可信身份传播后，可以通过 [IAM 身份中心的用户后台会话](https://docs.aws.amazon.com/singlesignon/latest/userguide/user-background-sessions.html)配置默认持续时间限制。

## 默认用户后台会话持续时间
<a name="default-user-background-session-duration"></a>

默认情况下，所有用户后台会话的持续时间限制为 7 天。管理员可以[在 IAM Identity Center 控制台中修改此持续时间](https://docs.aws.amazon.com/singlesignon/latest/userguide/user-background-sessions.html)。此设置在 IAM Identity Center 实例级别应用，会影响该实例内所有受支持的 IAM Identity Center 应用程序与 Studio 域。

启用可信身份传播后，管理员将在 SageMaker AI 控制台中找到包含以下信息的横幅：
+ 用户后台会话的持续时间限制
+ 指向 IAM Identity Center 控制台的链接，管理员可在该控制台中更改此配置
  + 持续时间可设置为 15 分钟到 90 天之间的任意值

当用户后台会话过期时，将出现一条错误消息。您可以使用 IAM Identity Center 控制台的链接更新持续时间。

## 在 Studio 中禁用可信身份传播的影响
<a name="user-background-session-impact-disable-trustedidentitypropagation-studio"></a>

如果管理员在最初启用可信身份传播后在 SageMaker AI 控制台中禁用了可信身份传播：
+ 当用户后台会话处于启用状态时，现有作业将继续运行且不会中断。
+ 禁用用户后台会话后，任何长时间运行的 SageMaker AI 工作流程或具有持续状态的作业都将切换到使用交互式会话。这包括但不限于维持执行状态或需要持续监控的任何 SageMaker AI 资源。例如，Amazon SageMaker 培训和处理任务。
+ 用户可以从检查点重新启动过期的作业。
+ 新作业使用 IAM 角色凭证运行，并且不传播身份上下文。

## 在 IAM Identity Center 控制台中禁用用户后台会话的影响
<a name="user-background-session-impact-disable-trustedidentitypropagation-identity-center"></a>

当 IAM Identity Center 实例**禁用**用户后台会话时，A SageMaker I 作业将使用用户交互式会话。使用交互式会话时，如果出现以下情况， SageMaker AI 作业将在 15 分钟内失败：
+ 用户注销
+ 管理员已撤销交互式会话

为 IAM Identity Center 实例**启用**用户后台会话后， SageMaker AI 作业将使用用户后台会话。使用交互式会话时，如果出现以下情况， SageMaker AI 作业将在 15 分钟内失败：
+ 用户后台会话过期
+ 管理员已手动撤销用户后台会话

以下提供了 SageMaker 训练作业的行为示例。当管理员在 IAM Identity Center 控制台中启用可信身份传播，但禁用[用户后台会话](https://docs.aws.amazon.com/singlesignon/latest/userguide/user-background-sessions.html)时：
+ 如果用户保持登录状态，则禁用后台会话时创建的训练作业将回退到交互式会话。
+ 如果用户注销，则该会话将过期，并且依赖交互式会话的训练作业将失败。
+ 用户可以从最后一个检查点重新启动其训练作业。会话持续时间由 IAM Identity Center 控制台中为交互式会话持续时间设置的值决定。
+ 如果用户在启动一个作业**后**禁用后台会话，该作业将继续使用其现有后台会话。换句话说， SageMaker AI 不会创建任何新的后台会话。

[如果在 IAM Identity Center 实例级别启用了后台会话，但专门针对使用 IAM 身份中心的 Studio 应用程序禁用了后台会话，则同样的行为适用 APIs。](https://docs.aws.amazon.com/singlesignon/latest/APIReference/welcome.html)

## 运行时系统注意事项
<a name="user-background-session-runtime-considerations"></a>

当管理员将长时间运行的训练或处理作业设置`MaxRuntimeInSeconds`为低于用户后台会话持续时间时， SageMaker AI 会在最短时间内运行该作业，`MaxRuntimeInSeconds`或者用户后台会话持续时间。有关 `MaxRuntimeInSeconds`的更多信息，请参阅[CreateTrainingJob](https://docs.aws.amazon.com/sagemaker/latest/APIReference/API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-StoppingCondition)。有关如何设置运行时的信息，请参阅 [IAM Identity Center 中的用户后台会话](https://docs.aws.amazon.com/singlesignon/latest/userguide/user-background-sessions.html)。

# 如何在启用了可信身份传播的情况下与其他 AWS 服务连接
<a name="trustedidentitypropagation-connect-other"></a>

当您的 Amazon A SageMaker I 域启用可信身份传播后，该域用户可以连接到其他支持可信身份传播的 AWS 服务。启用可信身份传播后，身份上下文会自动传播到可兼容的服务，从而实现精细访问控制并改进整个机器学习工作流的审计能力。这种集成消除了复杂的 IAM 角色切换的需求，并提供了跨 AWS 服务的统一身份体验。以下页面提供了有关在启用可信身份传播时如何将 Amazon SageMaker Studio 连接到其他 AWS 服务的信息。

**Topics**
+ [在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本连接到 Amazon S3 访问授权](trustedidentitypropagation-s3-access-grants.md)
+ [在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 Amazon EMR](trustedidentitypropagation-emr-ec2.md)
+ [在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 EMR Serverless](trustedidentitypropagation-emr-serverless.md)
+ [在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 Redshift 数据 API](trustedidentitypropagation-redshift-data-apis.md)
+ [在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 Lake Formation 和 Athena](trustedidentitypropagation-lake-formation-athena.md)

# 在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本连接到 Amazon S3 访问授权
<a name="trustedidentitypropagation-s3-access-grants"></a>

您可以使用 [Amazon S3 访问权限管控](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants.html)，灵活地授予对 Amazon S3 位置的基于身份的精细访问控制。这会将 Amazon S3 存储桶访问权限直接授予企业用户和组。以下页面提供了有关如何将 Amazon S3 访问权限授予与 A SageMaker I 的可信身份传播配合使用的信息和说明。

## 先决条件
<a name="s3-access-grants-prerequisites"></a>

要在启用了可信身份传播的情况下将 Studio 连接到 Lake Formation 和 Athena，请确保您已满足以下先决条件：
+  [为 Studio 设置可信身份传播](trustedidentitypropagation-setup.md) 
+ 按照[开始使用 Amazon S3 访问权限管控](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants-get-started.html)中的说明操作，为存储桶设置 Amazon S3 访问权限管控。有关更多信息，请参阅[使用 Amazon S3 访问权限管控扩展数据访问权限](https://aws.amazon.com/blogs/storage/scaling-data-access-with-amazon-s3-access-grants/)。
**注意**  
标准 Amazon S3 APIs 不能自动使用亚马逊 S3 访问授权。您必须明确使用 Amazon S3 访问授权 APIs。有关更多信息，请参阅[使用 Amazon S3 访问权限管控管理访问权限](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants.html)。

**Topics**
+ [先决条件](#s3-access-grants-prerequisites)
+ [将 Amazon S3 访问授权与 Studio JupyterLab 笔记本连接起来](s3-access-grants-setup.md)
+ [将 Connect Studio JupyterLab 笔记本电脑与包含培训和处理任务的 Amazon S3 访问权限授予](trustedidentitypropagation-s3-access-grants-jobs.md)

# 将 Amazon S3 访问授权与 Studio JupyterLab 笔记本连接起来
<a name="s3-access-grants-setup"></a>

使用以下信息在 Studio JupyterLab 笔记本中授予 Amazon S3 访问权限。

设置 Amazon S3 访问权限管控后，向域或用户[执行角色](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html#sagemaker-roles-get-execution-role)[添加以下权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html)。
+ `us-east-1` 是您的 AWS 区域
+ `111122223333` 是您的 AWS 账户 ID
+ `S3-ACCESS-GRANT-ROLE` 是您的 Amazon S3 访问权限管控角色

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowDataAccessAPI",
            "Effect": "Allow",
            "Action": [
                "s3:GetDataAccess"
            ],
            "Resource": [
                "arn:aws:s3:us-east-1:111122223333:access-grants/default"
            ]
        },
        {
            "Sid": "RequiredForTIP",
            "Effect": "Allow",
            "Action": "sts:SetContext",
            "Resource": "arn:aws:iam::111122223333:role/S3-ACCESS-GRANT-ROLE"
        }
    ]
}
```

------

确保您的 Amazon S3 访问权限管控角色的信任策略允许 `sts:SetContext` 和 `sts:AssumeRole` 操作。以下是在[更新角色信任策略](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_update-role-trust-policy.html)时使用的策略的示例。

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": {
                "Service": [
                    "access-grants.s3.amazonaws.com"
                ]
            },
            "Action": [
                "sts:AssumeRole",
                "sts:SetContext"
            ],
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "111122223333",
                    "aws:SourceArn": "arn:aws:s3:us-east-1:111122223333:access-grants/default"
                }
            }
        }
    ]
}
```

------

## 使用 Amazon S3 访问权限管控调用 Amazon S3
<a name="s3-access-grants-python-example"></a>

以下是 Python 脚本示例，说明了如何使用 Amazon S3 访问权限管控调用 Amazon S3。这假设您已经成功使用 SageMaker AI 设置了可信身份传播。

```
import boto3
from botocore.config import Config

def get_access_grant_credentials(account_id: str, target: str, 
                                 permission: str = 'READ'):
    s3control = boto3.client('s3control')
    response = s3control.get_data_access(
        AccountId=account_id,
        Target=target,
        Permission=permission
    )
    return response['Credentials']

def create_s3_client_from_credentials(credentials) -> boto3.client:
    return boto3.client(
        's3',
        aws_access_key_id=credentials['AccessKeyId'],
        aws_secret_access_key=credentials['SecretAccessKey'],
        aws_session_token=credentials['SessionToken']
    )

# Create client
credentials = get_access_grant_credentials('111122223333',
                                        "s3://tip-enabled-bucket/tip-enabled-path/")
s3 = create_s3_client_from_credentials(credentials)

s3.list_objects(Bucket="tip-enabled-bucket", Prefix="tip-enabled-path/")
```

如果使用未启用 Amazon S3 访问权限管控的 Amazon S3 存储桶的路径，则调用将失败。

有关其他编程语言，请参阅[使用 Amazon S3 访问权限管控管理访问权限](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-grants.html)以了解更多信息。

# 将 Connect Studio JupyterLab 笔记本电脑与包含培训和处理任务的 Amazon S3 访问权限授予
<a name="trustedidentitypropagation-s3-access-grants-jobs"></a>

使用以下信息授予 Amazon S3 访问权限，以访问亚马逊 SageMaker培训和处理任务中的数据。

当启用了可信身份传播的用户启动需要访问 Amazon S3 数据的 SageMaker 训练或处理任务时：
+ SageMaker AI 调用 Amazon S3 访问授权，以根据用户的身份获取临时证书
+ 如果此操作成功，这些临时凭证可用于访问 Amazon S3 数据
+ 如果不成功， SageMaker AI 会重新使用 IAM 角色证书

**注意**  
要强制通过 Amazon S3 访问权限管控授予所有权限，您需要移除执行角色的相关 Amazon S3 访问权限，并将其附加到相应的 [Amazon S3 访问权限管控](https://docs.aws.amazon.com/singlesignon/latest/userguide/tip-tutorial-s3.html#tip-tutorial-s3-create-grant)。

**Topics**
+ [注意事项](#s3-access-grants-jobs-considerations)
+ [使用训练和处理作业设置 Amazon S3 访问权限管控](#s3-access-grants-jobs-setup)

## 注意事项
<a name="s3-access-grants-jobs-considerations"></a>

Amazon S3 访问授权不能与 [Pipe 模式](https://docs.aws.amazon.com/sagemaker/latest/dg/augmented-manifest-stream.html)一起使用，用于对 Amazon S3 输入进行 SageMaker 训练和处理。

启用可信身份传播后，您无法启动具有以下功能的 T SageMaker raining Job
+ 远程调试
+ 调试器
+ Profiler

启用可信身份传播后，您无法启动具有以下功能的处理作业
+ DatasetDefinition

## 使用训练和处理作业设置 Amazon S3 访问权限管控
<a name="s3-access-grants-jobs-setup"></a>

设置 Amazon S3 访问权限管控后，向域或用户[执行角色](https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-roles.html#sagemaker-roles-get-execution-role)[添加以下权限](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_manage-attach-detach.html)。
+ `us-east-1` 是您的 AWS 区域
+ `111122223333` 是您的 AWS 账户 ID
+ `S3-ACCESS-GRANT-ROLE` 是您的 Amazon S3 访问权限管控角色

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

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "AllowDataAccessAPI",
            "Effect": "Allow",
            "Action": [
                "s3:GetDataAccess",
                "s3:GetAccessGrantsInstanceForPrefix"
            ],
            "Resource": [
                "arn:aws:s3:us-east-1:111122223333:access-grants/default"
            ]
        },
        {
            "Sid": "RequiredForIdentificationPropagation",
            "Effect": "Allow",
            "Action": "sts:SetContext",
            "Resource": "arn:aws:iam::111122223333:role/S3-ACCESS-GRANT-ROLE"
        }
    ]
}
```

------

# 在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 Amazon EMR
<a name="trustedidentitypropagation-emr-ec2"></a>

将 Amazon SageMaker Studio JupyterLab 笔记本电脑连接到 Amazon EMR 集群使您能够利用 Amazon EMR 的分布式计算能力来处理大规模的数据处理和分析工作负载。启用可信身份传播后，身份上下文将传播到 Amazon EMR，从而实现精细访问控制和全面的审计跟踪记录。以下页面提供有关如何将 Studio 笔记本连接到 Amazon EMR 集群的说明。设置完成后，可在 Studio 笔记本中使用 `Connect to Cluster` 选项。

要在启用了可信身份传播的情况下将 Studio 连接到 Amazon EMR，请确保您已完成以下设置：
+  [为 Studio 设置可信身份传播](trustedidentitypropagation-setup.md) 
+  [亚马逊 EM AWS IAM Identity Center R 集成入门](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-idc-start.html) 
+  [启用 Studio 和 Amazon EMR 集群之间的通信](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-notebooks-emr-cluster.html) 

 **连接到 Amazon EMR 集群** 

有关如何将 JupyterLab 笔记本电脑连接到 Amazon EMR 的完整选项列表，请参阅[连接到 Amazon EMR](https://docs.aws.amazon.com/sagemaker/latest/dg/connect-emr-clusters.html) 集群。

# 在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 EMR Serverless
<a name="trustedidentitypropagation-emr-serverless"></a>

Amazon EMR Serverless 提供了一个无服务器选项，可用于运行 Apache Spark 和 Apache Hive 应用程序，而无需管理集群。EMR Serverless 在与可信身份传播集成后，会自动扩展计算资源，并维护身份上下文以进行访问控制和审计。此方法消除了集群管理的运维开销，同时保留了基于身份的访问控制所带来的安全优势。以下部分提供了有关如何将启用了可信身份传播的 Studio 与 EMR Serverless 连接的信息。

要在启用了可信身份传播的情况下将 Studio 连接到 Amazon EMR Serverless，请确保您已完成以下设置：
+  [为 Studio 设置可信身份传播](trustedidentitypropagation-setup.md) 
+  [将可信身份传播与 EMR Serverless 集成](https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/security-iam-service-trusted-prop.html) 
+  [启用 Studio 和 EMR Serverless 之间的通信](https://docs.aws.amazon.com/sagemaker/latest/dg/studio-notebooks-emr-serverless.html) 

 **连接到 EMR Serverless 应用程序** 

有关如何将 JupyterLab 笔记本电脑连接到 EMR Serverless 的完整选项列表，请参阅[连接到 EMR Serverless](https://docs.aws.amazon.com/sagemaker/latest/dg/connect-emr-serverless-application.html) 应用程序。

# 在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 Redshift 数据 API
<a name="trustedidentitypropagation-redshift-data-apis"></a>

利用 Amazon Redshift Data API，您能够以编程方式与 Amazon Redshift 集群进行交互，而无需管理持久连接。Redshift Data API 在与可信身份传播结合使用时，可提供对数据仓库的安全的、基于身份的访问，这可让您运行 SQL 查询并检索结果，同时维护用户活动的完整审计跟踪记录。此集成对于需要访问存储在 Redshift 中的结构化数据的数据科学工作流特别有用。以下页面包含有关如何将可信身份传播与 Amazon SageMaker Studio 连接到 Redshift 数据 API 的信息和说明。

要在启用了可信身份传播的情况下将 Studio 连接到 Redshift Data API，请确保您已完成以下设置：
+  [为 Studio 设置可信身份传播](trustedidentitypropagation-setup.md) 
+  [将 Redshift Data API 与可信身份传播结合使用](https://docs.aws.amazon.com/redshift/latest/mgmt/data-api-trusted-identity-propagation.html) 
  + 确保执行角色具有 Redshift Data API 的相关权限。有关更多信息，请参阅[授权访问](https://docs.aws.amazon.com/redshift/latest/mgmt/data-api-access.html)。
+  [使用 Amazon Redshift 和外部身份 AWS Lake Formation 提供商中的用户简化访问管理](https://aws.amazon.com/blogs/big-data/simplify-access-management-with-amazon-redshift-and-aws-lake-formation-for-users-in-an-external-identity-provider/) 

# 在启用可信身份传播的情况下，将 Studio JupyterLab 笔记本电脑连接到 Lake Formation 和 Athena
<a name="trustedidentitypropagation-lake-formation-athena"></a>

AWS Lake Formation 与 Amazon Athena 合作提供全面的数据湖解决方案，具有精细的访问控制和无服务器查询功能。Lake Formation 为数据湖集中管理权限，而 Athena 则提供交互式查询服务。在与可信身份传播集成后，此组合可使数据科学家仅访问其有权查看的数据，并且系统会自动记录所有查询和数据访问以实现合规性与审计目的。以下页面提供了有关如何通过 Amazon SageMaker Studio 将可信身份传播与 Lake Formation 和 Athena 连接起来的信息和说明

要在启用了可信身份传播的情况下将 Studio 连接到 Lake Formation 和 Athena，请确保您已完成以下设置：
+  [为 Studio 设置可信身份传播](trustedidentitypropagation-setup.md) 
+  [创建 Lake Formation 角色](https://docs.aws.amazon.com/lake-formation/latest/dg/prerequisites-identity-center.html) 
+  [将 Lake Formation 与 IAM Identity Center 连接](https://docs.aws.amazon.com/lake-formation/latest/dg/connect-lf-identity-center.html) 
+ 创建 Lake Formation 资源：
  +  [数据库](https://docs.aws.amazon.com/lake-formation/latest/dg/creating-database.html) 
  +  [表](https://docs.aws.amazon.com/lake-formation/latest/dg/creating-tables.html) 
+  [创建 Athena 工作组](https://docs.aws.amazon.com/athena/latest/ug/creating-workgroups.html) 
  + 选择 **AthenaSQL** 作为引擎
  + 选择 **IAM Identity Center** 作为身份验证方法
  + 创建新的服务角色
    + 确保 IAM Identity Center 用户有权使用 Amazon S3 访问权限管控访问查询结果位置
+  [使用命名资源方法授予数据库权限](https://docs.aws.amazon.com/lake-formation/latest/dg/granting-database-permissions.html) 