

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

# 可信身份传播概述
<a name="trustedidentitypropagation-overview"></a>

可信身份传播是 IAM Identity Center 的一项功能，让 AWS 服务 的管理员可以根据用户属性（例如组关系）授予权限。通过可信身份传播，可以向 IAM 角色添加身份上下文，以识别请求访问 AWS 资源的用户。此上下文会传播到其他 AWS 服务上下文。

身份上下文包含在他们收到访问请求时 AWS 服务 用于做出授权决策的信息。这些信息包括识别请求者（例如，IAM 身份中心用户）、请求访问权限的元数据（例如 Amazon Redshift）和访问范围（例如，只读权限）的元数据。 AWS 服务 接收方 AWS 服务 使用此上下文以及分配给用户的任何权限来授权访问其资源。

## 可信身份传播的优势
<a name="benefits-trusted-identity-propagation"></a>

可信身份传播允许管理员使用员工的 AWS 服务 企业身份授予对资源（例如数据）的权限。此外，他们还可以通过查看服务日志或来审核谁访问了哪些数据 AWS CloudTrail。如果您是 IAM Identity Center 管理员，其他 AWS 服务 管理员可能会要求您启用可信身份传播。

## 启用可信身份传播
<a name="enabling-tip"></a>

启用可信身份传播的流程包括以下两个步骤：

1. **启用 IAM Identity Center 并将您现有的身份来源连接到 IAM Identity Center**-您将继续使用现有身份来源管理员工身份；将其连接到 IAM Identity Center 可创建对您的员工的引用，供您的用例 AWS 服务 中的所有人共享。数据所有者也可在未来的使用案例中使用该引用。

1. 将@@ **您的用例中的 IAM Identity Center 连接到 IAM Identity Center**-可信身份传播用例中的管理员遵循相应服务文档中的指导将服务连接到 IAM Identity Center。 AWS 服务 AWS 服务 

**注意**  
如果您的使用案例涉及*第三方*或*客户开发的应用程序*，您可以通过在验证应用程序用户身份的身份提供者和 IAM Identity Center 之间配置信任关系来启用可信身份传播。这样，您的应用程序就能利用前文所述的可信身份传播流程。  
有关更多信息，请参阅 [通过可信令牌发布者使用应用程序](using-apps-with-trusted-token-issuer.md)。

## 可信身份传播如何工作
<a name="how-tip-works"></a>

下图展示了可信身份传播的高层级工作流：

![\[简化的可信身份传播工作流。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/simplied-tip-1.png)


1. 用户使用面向客户端的应用程序（例如 Quick）进行身份验证。

1. 面向客户的应用程序请求访问权限以使用 AWS 服务 来查询数据，并包含有关用户的信息。
**注意**  
一些可信身份传播用例涉及与 AWS 服务 使用服务驱动程序进行交互的工具。您可以在[使用案例指南](trustedidentitypropagation-integrations.md)中查看这是否适用于您的使用案例。

1. 使用 IAM Identity Center AWS 服务 验证用户身份，并将用户属性（例如群组关联）与访问所需的属性进行比较。只要用户或其组具有必要的权限，就会 AWS 服务 授予访问权限。

1. AWS 服务 可能会将用户标识符记录在服务日志中 AWS CloudTrail 和服务日志中。有关详细信息，请参阅相应服务文档。

下图概述了前文所述的可信身份传播工作流步骤：

![\[简化的可信身份传播工作流。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/simplied-tip-2.png)


**Topics**
+ [可信身份传播的优势](#benefits-trusted-identity-propagation)
+ [启用可信身份传播](#enabling-tip)
+ [可信身份传播如何工作](#how-tip-works)
+ [先决条件和注意事项](trustedidentitypropagation-overall-prerequisites.md)
+ [可信身份传播应用场景](trustedidentitypropagation-integrations.md)
+ [授权服务](authorization-services.md)

# 先决条件和注意事项
<a name="trustedidentitypropagation-overall-prerequisites"></a>

在设置可信身份传播之前，请先查看以下先决条件和注意事项。

**Topics**
+ [先决条件](#trustedidentitypropagation-prerequisites)
+ [注意事项](#trustedidentitypropagation-considerations)
+ [客户自主管理型应用程序的注意事项](#trustedidentitypropagation-customer-apps)

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

要使用可信身份传播，请确保您的环境满足以下先决条件：
+ 启用和预置 IAM Identity Center
  + 要使用可信身份传播，您必须在启用用户将要访问的 AWS 应用程序和服务的相同 AWS 区域 位置启用 IAM Identity Center。有关信息，请参阅[启用 IAM Identity Center](enable-identity-center.md)。
    + 推荐使用 IAM Identity Center 组织实例 - 我们建议您使用在 AWS Organizations管理账户中启用的 IAM Identity Center [组织实例](organization-instances-identity-center.md)。您可以将 IAM Identity Center 组织实例的[管理权限委托](organization-instances-identity-center.md)给成员账户。如果您选择 IAM Identity Center 的[账户实例](account-instances-identity-center.md)，则所有希望用户通过可信身份传播访问的 AWS 服务 必须位于您启用 IAM Identity Center 的同一 AWS 账户 中。有关更多信息，请参阅 [IAM Identity Center 的账户实例](account-instances-identity-center.md)。
  + 将您现有的身份提供者连接到 IAM Identity Center，并将用户和组配置到 IAM Identity Center 中。有关更多信息，请参阅 [IAM Identity Center 身份源教程](tutorials.md)。
+ 将您的可信身份传播用例中的 AWS 托管应用程序和服务连接到 IAM Identity Center。要使用可信身份传播， AWS 托管应用程序必须连接到 IAM 身份中心。

## 注意事项
<a name="trustedidentitypropagation-considerations"></a>

配置和使用可信身份传播时，请记住以下注意事项：
+ **IAM Identity Center 的组织和账户实例**
  + IAM Identity Center 的[组织实例](organization-instances-identity-center.md)能为您提供最大的控制权和灵活性，支持将使用案例扩展到多个 AWS 账户、用户和 AWS 服务。如果您无法使用组织实例，您的使用案例可能支持通过 IAM Identity Center 的账户实例实现。有关您使用案例中的哪些 AWS 服务 支持 IAM Identity Center 账户实例，请参阅 [AWS 可与 IAM 身份中心配合使用的托管应用程序](awsapps-that-work-with-identity-center.md)。
+ **不需要多账户权限（权限集）**
  + 可信身份传播不需要您设置[多账户权限](manage-your-accounts.md)（权限集）。您可以启用 IAM Identity Center，仅将其用于可信身份传播。

## 客户自主管理型应用程序的注意事项
<a name="trustedidentitypropagation-customer-apps"></a>

即使您的用户与不由 AWS您定制开发的应用程序管理的面向客户的应用程序进行交互，您的员工也可以从可信的身份Tableau传播中受益。这些应用程序的用户可能未在 IAM Identity Center 中配置。为了顺利识别和授权用户访问 AWS 资源，IAM Identity Center 允许您在对用户进行身份验证的身份提供商与 IAM Identity Center 之间配置可信关系。有关更多信息，请参阅 [通过可信令牌发布者使用应用程序](using-apps-with-trusted-token-issuer.md)。

此外，为您的应用程序配置可信身份传播还需满足以下要求：
+ 您的应用程序必须使用 OAuth 2.0 框架进行身份验证。可信身份传播不支持 SAML 2.0 集成。
+ 您的应用程序必须获得 IAM Identity Center 的认可。请遵循您的[使用案例](trustedidentitypropagation-integrations.md)专属指引。

# 可信身份传播应用场景
<a name="trustedidentitypropagation-integrations"></a>

作为 IAM Identity Center 管理员，您可能需要协助配置从面向用户的应用程序到 AWS 服务的可信身份传播。为支持此请求，您需要以下信息：
+ 您的用户将使用哪个面向客户端的应用程序？
+  AWS 服务 哪些用于查询数据和授权访问数据？
+ 哪个 AWS 服务 授权访问数据？

在启用**不涉及第三方应用程序或自定义开发应用程序的可信身份传播使用案例**时，您的职责包括：

1. [启用 IAM 身份中心](enable-identity-center.md)。

1. [将现有身份源连接到 IAM Identity Center](tutorials.md)。

这些用例的可信身份配置的其余步骤将在连接 AWS 服务 的应用程序中执行。已连接 AWS 服务 或应用程序的管理员应参阅相应的用户指南，以获得全面的服务特定指导。

在启用**涉及第三方应用程序或自定义开发应用程序的可信身份传播使用案例**时，您的职责包括 [启用 IAM Identity Center](enable-identity-center.md) 和[连接身份源](tutorials.md)的步骤，以及：

1. 配置身份提供者（IdP）与第三方或自定义开发应用程序的连接。

1. 使 IAM Identity Center 能够识别该第三方或自定义开发应用程序。

1. 在 IAM Identity Center 中将您的 IdP 配置为可信令牌颁发者。有关更多信息，请参阅 [通过可信令牌发布者使用应用程序](using-apps-with-trusted-token-issuer.md)。

所连接应用程序的管理员 AWS 服务 应参阅相应的用户指南，以获得全面的服务特定指导。

## 分析、数据湖仓和机器学习使用案例
<a name="tip-data-analytic-usecases-overview"></a>

您可以通过以下分析和机器学习服务启用可信传播使用案例：
+ **Amazon Redshift** - 有关指导，请参阅 [使用 Amazon Redshift 的可信身份传播](tip-usecase-redshift.md)。
+ **Amazon EMR** - 有关指导，请参阅 [使用 Amazon EMR 的可信身份传播](tip-usecase-emr.md)。
+ **Amazon Athena** - 有关指导，请参阅 [使用 Amazon Athena 的可信身份传播](tip-usecase-ate.md)。
+ **SageMaker Studio**-有关指导，请参阅[使用 Amazon SageMaker Studio 进行可信身份传](trusted-identity-propagation-usecase-sagemaker-studio.md)。

## 其他使用案例
<a name="tip-additional-usecases"></a>

您还可以通过以下 AWS 服务启用 IAM Identity Center 和可信身份传播：
+ **Amazon Q Business** - 有关指导，请参阅：
  + [使用 IAM Identity Center 的应用程序的管理员工作流](https://docs.aws.amazon.com//amazonq/latest/qbusiness-ug/how-it-works.html#admin-flow-idc)
  + [使用 IAM Identity Center 配置 Amazon Q Business 应用程序](https://docs.aws.amazon.com//amazonq/latest/qbusiness-ug/create-application.html)。
  + [使用 IAM Identity Center 可信身份传播配置 Amazon Q Business](https://aws.amazon.com/blogs//machine-learning/configuring-amazon-q-business-with-aws-iam-identity-center-trusted-identity-propagation/)。
+ **Amazon OpenSearch 服务**-有关指导，请参阅：
  + [IAM Identity Center 可信身份传播支持 Amazon OpenSearch 服务](https://docs.aws.amazon.com//opensearch-service/latest/developerguide/idc-aos.html)。
  + [Amazon OpenSearch 服务的集中式 OpenSearch 用户界面（控制面板）](https://docs.aws.amazon.com//opensearch-service/latest/developerguide/application.html)。
+ **AWS Transfer Family** - 有关指导，请参阅：
  + [Transfer Family Web 应用程序](https://docs.aws.amazon.com//transfer/latest/userguide/web-app.html)。

**Topics**
+ [分析、数据湖仓和机器学习使用案例](#tip-data-analytic-usecases-overview)
+ [其他使用案例](#tip-additional-usecases)
+ [使用 Amazon Redshift 的可信身份传播](tip-usecase-redshift.md)
+ [使用 Amazon EMR 的可信身份传播](tip-usecase-emr.md)
+ [使用 Amazon Athena 的可信身份传播](tip-usecase-ate.md)
+ [使用 Amazon SageMaker Studio 进行可信身份传](trusted-identity-propagation-usecase-sagemaker-studio.md)

# 使用 Amazon Redshift 的可信身份传播
<a name="tip-usecase-redshift"></a>

启用可信身份传播的步骤取决于您的用户是与托管应用程序交互还是与客户 AWS 托管的应用程序进行交互。下图显示了面向客户端的应用程序（无论是 AWS 托管的还是外部的）的可信身份传播配置，这些应用程序通过Amazon Redshift或授权服务（例如Amazon S3）提供的访问控制来查询 Amazon Redshift 数据。 AWS AWS Lake Formation Access Grants

![\[使用 Amazon Redshift、Quick、Lake Formation 和 IAM 身份中心进行可信身份传播示意图\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/rs-tip-diagram.png)


启用面向 Amazon Redshift 的可信身份传播后，Redshift 管理员可以将 Redshift 配置为[自动创建角色](https://docs.aws.amazon.com//redshift/latest/mgmt/redshift-iam-access-control-sso-autocreate.html)（以 IAM Identity Center 作为身份提供者）、将 Redshift 角色映射到 IAM Identity Center 中的组，并使用 [Redshift 基于角色的访问控制授予访问权限](https://docs.aws.amazon.com//redshift/latest/dg/r_tutorial-RBAC.html)。

## 支持的面向客户端的应用程序
<a name="redshift-mgn-apps-and-customer-apps"></a>

**AWS 托管应用程序**  
以下面向客户的 AWS 托管应用程序支持向 Amazon Redshift 传播可信身份：
+ [Amazon RedshiftQuery Editor V2](setting-up-tip-redshift.md)
+ [快点](https://docs.aws.amazon.com//quicksight/latest/user/redshift-trusted-identity-propagation.html)

**注意**  
如果您使用 Amazon Redshift Spectrum 访问 AWS Glue Data Catalog中的外部数据库或表，建议设置 [Lake Formation](tip-tutorial-lf.md) 和 [Amazon S3 Access Grants](tip-tutorial-s3.md) 以提供细粒度访问控制。

**客户托管的应用程序**  
以下客户自主管理型应用程序支持面向 Amazon Redshift 的可信身份传播：
+ **Tableau**，包括 Tableau Desktop、Tableau Server 和 Tableau Prep
  + 要为 Tableau 用户启用可信身份传播，请参阅《*AWS 大数据博客*》中的[使用 IAM Identity Center 将 Tableau 和 Okta 与 Amazon Redshift 集成](https://aws.amazon.com/blogs//big-data/integrate-tableau-and-okta-with-amazon-redshift-using-aws-iam-identity-center/)。
+ **SQL 客户端**（DBeaver 和 DBVisualizer）
  + 要为 SQL 客户端（DBeaver 和 DBVisualizer）用户启用可信身份传播，请参阅《*AWS 大数据博客*》中的[使用 IAM Identity Center 将身份提供者（IdP）与 Amazon Redshift 查询编辑器 V2 和 SQL 客户端集成以实现无缝单点登录](https://aws.amazon.com/blogs//big-data/integrate-identity-provider-idp-with-amazon-redshift-query-editor-v2-and-sql-client-using-aws-iam-identity-center-for-seamless-single-sign-on/)。

# 设置 Amazon Redshift 查询编辑器 V2 的可信身份传播
<a name="setting-up-tip-redshift"></a>

以下过程将引导您实现从 Amazon Redshift 查询编辑器 V2 到 Amazon Redshift 的可信身份传播。

## 先决条件
<a name="setting-up-tip-redshift-prereqs"></a>

在开始本教程之前，您需要设置以下方面：

1. [启用 IAM 身份中心](enable-identity-center.md)。建议使用[组织实例](organization-instances-identity-center.md)。有关更多信息，请参阅 [先决条件和注意事项](trustedidentitypropagation-overall-prerequisites.md)。

1. [将身份源中的用户和组配置到 IAM Identity Center](tutorials.md)。

启用可信身份传播涉及两项操作：IAM Identity Center 管理员在 IAM Identity Center 控制台执行的任务，以及 Amazon Redshift 管理员在 Amazon Redshift 控制台执行的任务。

## IAM Identity Center 管理员需执行的任务
<a name="setting-up-tip-redshift-ssoadmin-tasks"></a>

IAM Identity Center 管理员需完成以下任务：

1. 在 Amazon Redshift 集群或无服务器实例所在的账户中，**创建 [IAM 角色](https://docs.aws.amazon.com//IAM/latest/UserGuide/id_roles.html)** 并附加以下权限策略。有关更多信息，请参阅 [IAM 角色创建](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create.html)。

   1. 以下策略示例包含完成本教程所需的权限。要使用此政策，请将示例策略*italicized placeholder text*中的替换为您自己的信息。有关详细操作指引，请参阅[创建策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_create.html)或[编辑策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_manage-edit.html)。

     **权限策略：**

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

****  

     ```
     {
         "Version":"2012-10-17",		 	 	 
         "Statement": [
             {
                 "Sid": "AllowRedshiftApplication",
                 "Effect": "Allow",
                 "Action": [
                     "redshift:DescribeQev2IdcApplications",
                     "redshift-serverless:ListNamespaces",
                     "redshift-serverless:ListWorkgroups",
                     "redshift-serverless:GetWorkgroup"
                 ],
                 "Resource": "*"
             },
             {
                 "Sid": "AllowIDCPermissions",
                 "Effect": "Allow",
                 "Action": [
                     "sso:DescribeApplication",
                     "sso:DescribeInstance"
                 ],
                 "Resource": [
                     "arn:aws:sso:::instance/Your-IAM-Identity-Center-Instance ID",
                     "arn:aws:sso::111122223333:application/Your-IAM-Identity-Center-Instance-ID/*"
                 ]
             }
         ]
     }
     ```

------

     **信任政策：**

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

****  

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

------

1. 在启用 IAM Identity Center 的 AWS Organizations 管理账户中**创建权限集**。下一步将使用该权限集允许联合用户访问 Redshift 查询编辑器 V2。

   1. 访问 **IAM Identity Center** 控制台，在**多账户权限**下选择**权限集**。

   1. 选择**创建权限集**。

   1. 选择**自定义权限集**，然后选择**下一步**。

   1. 在 **AWS 托管策略**下，选择 **`AmazonRedshiftQueryEditorV2ReadSharing`**。

   1. 在**内联策略**下，添加以下策略：

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

****  

      ```
      {
          "Version":"2012-10-17",		 	 	 
          "Statement": [
              {
                  "Sid": "Statement1",
                  "Effect": "Allow",
                  "Action": [
                      "redshift:DescribeQev2IdcApplications",
                      "redshift-serverless:ListNamespaces",
                      "redshift-serverless:ListWorkgroups",
                      "redshift-serverless:GetWorkgroup"
                  ],
                  "Resource": "*"
              }
          ]
      }
      ```

------

   1. 选择**下一步**，然后为权限集命名。例如 **Redshift-Query-Editor-V2**。

   1. 在**中继状态 - 可选**下，将默认中继状态设置为查询编辑器 V2 URL，格式为：`https://your-region.console.aws.amazon.com/sqlworkbench/home`。

   1. 检查设置，然后选择**创建**。

   1. 导航到 IAM Identity Center 仪表板，并从**设置摘要**部分复制 AWS 访问门户 URL。  
![\[第 i 步，从 IAM 身份中心控制台复制 AWS 访问门户 URL。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/setting-up-redshift-step-i.png)

   1. 打开一个新的隐身浏览器窗口并粘贴该 URL。

      这将带您 AWS 进入访问门户，确保您使用的是 IAM Identity Center 用户登录。  
![\[步骤 j，登录 AWS 访问门户。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/setting-up-redshift-step-j.png)

      有关权限集的更多信息，请参阅 [AWS 账户 使用权限集进行管理](permissionsetsconcept.md)。

1. **启用联合用户访问 Redshift 查询编辑器 V2**。

   1. 在 AWS Organizations 管理账户中，打开 **IAM 身份中心**控制台。

   1. 在导航窗格中的**多帐户权限**下，选择 **AWS 账户**。

   1. 在 AWS 账户 页面上，选择 AWS 账户 要为其分配访问权限的。

   1. 选择**分配用户或组**。

   1. 在**分配用户和组**页面上，选择要为其创建权限集的用户和/或组。然后选择**下一步**。

   1. 在**分配权限集**页面上，选择您在上一步中创建的权限集。然后选择**下一步**。

   1. 在**查看并提交分配**页面上，查看您的选择，选择**提交**。

## Amazon Redshift 管理员执行的任务
<a name="setting-up-tip-redshift-admin-tasks"></a>

启用面向 Amazon Redshift 的可信身份传播，需要 Amazon Redshift 集群管理员或 Amazon Redshift Serverless 管理员在 Amazon Redshift 控制台执行多项操作。有关更多信息，请参阅《*AWS 大数据博客*》中的[使用 IAM Identity Center 将身份提供者（IdP）与 Amazon Redshift 查询编辑器 V2 和 SQL 客户端集成以实现无缝单点登录](https://aws.amazon.com/blogs//big-data/integrate-identity-provider-idp-with-amazon-redshift-query-editor-v2-and-sql-client-using-aws-iam-identity-center-for-seamless-single-sign-on/)。

# 使用 Amazon EMR 的可信身份传播
<a name="tip-usecase-emr"></a>

下图显示了 Amazon EMR Studio 的可信身份传播配置，使用亚马逊 EC2 上的 Amazon EMR，访问控制由和 Amaz AWS Lake Formation on S3 提供。Access Grants

![\[使用 Amazon EMR、Lake Formation 和 IAM Identity Center 的可信身份传播示意图\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/emr-tip-diagram.png)


**支持的面向客户端的应用程序**
+ Amazon EMR Studio

**如需启用可信身份传播，请执行以下步骤：**
+ [设置 Amazon EMR Studio](setting-up-tip-emr.md) 作为 Amazon EMR 集群的面向客户端应用程序。
+ 设置[搭载 Apache Spark 的 Amazon EC2 上的 Amazon EMR 集群](https://docs.aws.amazon.com//emr/latest/ManagementGuide/emr-idc-start.html)。
+ *推荐*：[AWS Lake Formation](tip-tutorial-lf.md)以及 [Amazon S3 Access Grants](tip-tutorial-s3.md)，以提供对 S3 中底层数据位置 AWS Glue Data Catalog 和底层数据位置的精细访问控制。

# 设置 Amazon EMR Studio 的可信身份传播
<a name="setting-up-tip-emr"></a>

以下过程将引导您设置 Amazon EMR Studio，以实现对 Amazon Athena 工作组或运行 Apache Spark 的 Amazon EMR 集群执行查询时的可信身份传播。

## 先决条件
<a name="setting-up-tip-emr-prereqs"></a>

在开始本教程之前，您需要设置以下方面：

1. [启用 IAM 身份中心](enable-identity-center.md)。建议使用[组织实例](organization-instances-identity-center.md)。有关更多信息，请参阅 [先决条件和注意事项](trustedidentitypropagation-overall-prerequisites.md)。

1. [将身份源中的用户和组配置到 IAM Identity Center](tutorials.md)。

要完成 Amazon EMR Studio 的可信身份传播配置，EMR Studio 管理员必须执行以下步骤。

## 步骤 1：为 EMR Studio 创建所需的 IAM 角色
<a name="setting-up-tip-emr-step1"></a>

本步骤中，Amazon EMR Studio 管理员需为 EMR Studio 创建 IAM 服务角色和 IAM 用户角色。

1. **[创建 EMR Studio 服务角色](https://docs.aws.amazon.com//emr/latest/ManagementGuide/emr-studio-service-role.html)** - EMR Studio 将通过该 IAM 角色安全管理工作区和笔记本、连接集群并处理数据交互。

   1. 导航到 IAM 控制台 ([https://console.aws.amazon.com/iam/](https://console.aws.amazon.com/iam/)) 并创建 IAM 角色。

   1. 选择 **AWS 服务** 作为可信实体，然后选择 **Amazon EMR**。附加以下策略以定义该角色的权限和信任关系。

      要使用这些政策，请将示例策略*italicized placeholder text*中的替换为您自己的信息。有关详细操作指引，请参阅[创建策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_create.html)或[编辑策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_manage-edit.html)。

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

****  

      ```
      {
          "Version":"2012-10-17",		 	 	 
          "Statement": [
              {
                  "Sid": "ObjectActions",
                  "Effect": "Allow",
                  "Action": [
                      "s3:PutObject",
                      "s3:GetObject",
                      "s3:DeleteObject"
                  ],
                  "Resource": [
                      "arn:aws:s3:::Your-S3-Bucket-For-EMR-Studio/*"
                  ],
                  "Condition": {
                      "StringEquals": {
                          "aws:ResourceAccount": "Your-AWS-Account-ID"
                      }
                  }
              },
              {
                  "Sid": "BucketActions",
                  "Effect": "Allow",
                  "Action": [
                      "s3:ListBucket",
                      "s3:GetEncryptionConfiguration"
                  ],
                  "Resource": [
                      "arn:aws:s3:::Your-S3-Bucket-For-EMR-Studio"
                  ],
                  "Condition": {
                      "StringEquals": {
                          "aws:ResourceAccount": "Your-AWS-Account-ID"
                      }
                  }
              }
          ]
      }
      ```

------

      有关服务角色的所有权限参考，请参阅 [EMR Studio 服务角色权限](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-studio-service-role.html#emr-studio-service-role-permissions-table)。

1. **[创建用于 IAM Identity Center 身份验证的 EMR Studio 用户角色](https://docs.aws.amazon.com//emr/latest/ManagementGuide/emr-studio-user-permissions.html#emr-studio-create-user-role)** - 当用户通过 IAM Identity Center 登录以管理工作区、EMR 集群、作业和 Git 代码库时，EMR Studio 将使用该角色。**该角色用于启动可信身份传播工作流**。
**注意**  
EMR Studio 用户角色不需要包含访问目录中 AWS Glue 表的 Amazon S3 位置的权限。 AWS Lake Formation 权限和注册的湖泊位置将用于获得临时权限。

   以下示例策略可用于允许 EMR Studio 用户通过 Athena 工作组运行查询的角色。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Sid": "AllowDefaultEC2SecurityGroupsCreationInVPCWithEMRTags",
               "Effect": "Allow",
               "Action": [
                   "ec2:CreateSecurityGroup"
               ],
               "Resource": [
                   "arn:aws:ec2:*:*:vpc/*"
               ],
               "Condition": {
                   "StringEquals": {
                       "aws:ResourceTag/for-use-with-amazon-emr-managed-policies": "true"
                   }
               }
           },
           {
               "Sid": "AllowAddingEMRTagsDuringDefaultSecurityGroupCreation",
               "Effect": "Allow",
               "Action": [
                   "ec2:CreateTags"
               ],
               "Resource": "arn:aws:ec2:*:*:security-group/*",
               "Condition": {
                   "StringEquals": {
                       "aws:RequestTag/for-use-with-amazon-emr-managed-policies": "true",
                       "ec2:CreateAction": "CreateSecurityGroup"
                   }
               }
           },
           {
               "Sid": "AllowSecretManagerListSecrets",
               "Action": [
                   "secretsmanager:ListSecrets"
               ],
               "Resource": "*",
               "Effect": "Allow"
           },
           {
               "Sid": "AllowSecretCreationWithEMRTagsAndEMRStudioPrefix",
               "Effect": "Allow",
               "Action": "secretsmanager:CreateSecret",
               "Resource": "arn:aws:secretsmanager:*:*:secret:emr-studio-*",
               "Condition": {
                   "StringEquals": {
                       "aws:RequestTag/for-use-with-amazon-emr-managed-policies": "true"
                   }
               }
           },
           {
               "Sid": "AllowAddingTagsOnSecretsWithEMRStudioPrefix",
               "Effect": "Allow",
               "Action": "secretsmanager:TagResource",
               "Resource": "arn:aws:secretsmanager:*:*:secret:emr-studio-*"
           },
           {
               "Sid": "AllowPassingServiceRoleForWorkspaceCreation",
               "Action": "iam:PassRole",
               "Resource": [
                   "arn:aws:iam::111122223333:role/service-role/AmazonEMRStudio_ServiceRole_Name"
               ],
               "Effect": "Allow"
           },
           {
               "Sid": "AllowS3ListAndLocationPermissions",
               "Action": [
                   "s3:ListAllMyBuckets",
                   "s3:ListBucket",
                   "s3:GetBucketLocation"
               ],
               "Resource": "arn:aws:s3:::*",
               "Effect": "Allow"
           },
           {
               "Sid": "AllowS3ReadOnlyAccessToLogs",
               "Action": [
                   "s3:GetObject"
               ],
               "Resource": [
                   "arn:aws:s3:::aws-logs-Your-AWS-Account-ID-Region/elasticmapreduce/*"
               ],
               "Effect": "Allow"
           },
           {
               "Sid": "AllowAthenaQueryExecutions",
               "Effect": "Allow",
               "Action": [
                   "athena:StartQueryExecution",
                   "athena:GetQueryExecution",
                   "athena:GetQueryResults",
                   "athena:StopQueryExecution",
                   "athena:ListQueryExecutions",
                   "athena:GetQueryResultsStream",
                   "athena:ListWorkGroups",
                   "athena:GetWorkGroup",
                   "athena:CreatePreparedStatement",
                   "athena:GetPreparedStatement",
                   "athena:DeletePreparedStatement"
               ],
               "Resource": "*"
           },
           {
               "Sid": "AllowGlueSchemaManipulations",
               "Effect": "Allow",
               "Action": [
                   "glue:GetDatabase",
                   "glue:GetDatabases",
                   "glue:GetTable",
                   "glue:GetTables",
                   "glue:GetPartition",
                   "glue:GetPartitions"
               ],
               "Resource": "*"
           },
           {
               "Sid": "AllowQueryEditorToAccessWorkGroup",
               "Effect": "Allow",
               "Action": "athena:GetWorkGroup",
               "Resource": "arn:aws:athena:*:111122223333:workgroup*"
           },
           {
               "Sid": "AllowConfigurationForWorkspaceCollaboration",
               "Action": [
                   "elasticmapreduce:UpdateEditor",
                   "elasticmapreduce:PutWorkspaceAccess",
                   "elasticmapreduce:DeleteWorkspaceAccess",
                   "elasticmapreduce:ListWorkspaceAccessIdentities"
               ],
               "Resource": "*",
               "Effect": "Allow",
               "Condition": {
                   "StringEquals": {
                       "elasticmapreduce:ResourceTag/creatorUserId": "${aws:userId}"
                   }
               }
           },
           {
               "Sid": "DescribeNetwork",
               "Effect": "Allow",
               "Action": [
                   "ec2:DescribeVpcs",
                   "ec2:DescribeSubnets",
                   "ec2:DescribeSecurityGroups"
               ],
               "Resource": "*"
           },
           {
               "Sid": "ListIAMRoles",
               "Effect": "Allow",
               "Action": [
                   "iam:ListRoles"
               ],
               "Resource": "*"
           },
           {
               "Sid": "AssumeRole",
               "Effect": "Allow",
               "Action": [
                   "sts:AssumeRole"
               ],
               "Resource": "*"
           }
       ]
   }
   ```

------

   以下信任策略允许 EMR Studio 扮演该角色：
**注意**  
使用 EMR Studio 工作区和 EMR 笔记本需额外配置权限。有关更多信息，请参阅[为 EMR Studio 用户创建权限策略](https://docs.aws.amazon.com//emr/latest/ManagementGuide/emr-studio-user-permissions.html#emr-studio-permissions-policies)。

**您可通过以下链接获取更多信息：**
   + [使用客户管理型策略定义自定义 IAM 权限](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_create.html)
   + [EMR Studio 服务角色权限](https://docs.aws.amazon.com//emr/latest/ManagementGuide/emr-studio-service-role.html#emr-studio-service-role-permissions-table)

## 步骤 2：创建并配置 EMR Studio
<a name="setting-up-tip-emr-step2"></a>

本步骤中，您将在 EMR Studio 控制台创建 Amazon EMR Studio，并使用在 [步骤 1：为 EMR Studio 创建所需的 IAM 角色步骤 2：创建并配置 EMR Studio](#setting-up-tip-emr-step1) 中创建的 IAM 角色。

1. 访问 EMR Studio 控制台，选择**创建 Studio** 并选择**自定义设置**选项。您可以创建新的 S3 存储桶或使用现有存储桶。您可勾选**使用自己的 KMS 密钥加密工作区文件**选项。有关更多信息，请参阅 [AWS Key Management Service](https://docs.aws.amazon.com//kms/latest/developerguide/overview.html)。  
![\[步骤 1：在 EMR 控制台创建 EMR Studio。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/emr-tutorial-step-3.1.png)

1. 在**允许 Studio 访问您资源的服务角色**下，从下拉菜单中选择在 [步骤 1：为 EMR Studio 创建所需的 IAM 角色步骤 2：创建并配置 EMR Studio](#setting-up-tip-emr-step1) 中创建的服务角色。

1. 在**身份验证**下选择 **IAM Identity Center**。选择在 [步骤 1：为 EMR Studio 创建所需的 IAM 角色步骤 2：创建并配置 EMR Studio](#setting-up-tip-emr-step1) 中创建的用户角色。  
![\[步骤 3：在 EMR 控制台创建 EMR Studio，选择 IAM Identity Center 作为身份验证方式。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/emr-tutorial-step-3.3.png)

1. 勾选**可信身份传播**选项框。在应用程序访问部分选择**仅已分配的用户和组**，这样仅授权的用户和组可访问该 Studio。

1. *（可选）*– 如果您将该 Studio 与 EMR 集群配合使用，可配置 VPC 和子网。  
![\[步骤 4：在 EMR 控制台创建 EMR Studio，配置网络和安全设置。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/emr-tutorial-step-3.4.png)

1. 审核所有详细信息并选择**创建 Studio**。

1. 配置 Athen WorkGroup a 或 EMR 集群后，请登录 Studio 的 URL，以：

   1. 通过查询编辑器运行 Athena 查询。

   1. 在工作区中通过 Jupyter Notebook 运行 Spark 作业。

# 使用 Amazon Athena 的可信身份传播
<a name="tip-usecase-ate"></a>

启用可信身份传播的步骤取决于您的用户是与托管应用程序交互还是与客户 AWS 托管的应用程序进行交互。下图显示了面向客户端的应用程序（无论是 AWS 托管应用程序还是外部应用程序）的可信身份传播配置，该配置使用 Amazon Athena 通过 AWS Lake Formation 和 Amazon S3 提供的访问控制来 AWS 查询 Amazon S3 数据。Access Grants

**注意**  
Amazon Athena 的可信身份传播需使用 Trino。
不支持通过 ODBC 和 JDBC 驱动程序连接到 Amazon Athena 的 Apache Spark 和 SQL 客户端。

![\[使用 Athena、Amazon EMR、Lake Formation 和 IAM Identity Center 的可信身份传播示意图\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/ate-tip-diagram.png)


**AWS 托管应用程序**

以下面向客户端的 AWS 托管应用程序支持通过 Athena 进行可信身份传播：
+ Amazon EMR Studio

**如需启用可信身份传播，请执行以下步骤：**
+ [设置 Amazon EMR Studio](setting-up-tip-emr.md) 作为 Athena 的面向客户端应用程序。启用可信身份传播后，需通过 EMR Studio 中的查询编辑器运行 Athena 查询。
+ [设置 Athena 工作组](setting-up-tip-ate.md)。
+ [设置 AWS Lake Formation为](tip-tutorial-lf.md)根据 IAM Identity Center 中的用户或群组对 AWS Glue 表启用精细访问控制。
+ [设置 Amazon S3 Access Grants](tip-tutorial-s3.md)，以便允许临时访问 S3 中的底层数据位置。

**注意**  
Lake Formation 和 Amazon S3 Access Grants 都需要对亚马逊 S3 中的 Athena 查询结果进行访问控制。 AWS Glue Data Catalog 

**客户托管的应用程序**  
要为*自定义开发的应用程序*的用户启用可信身份传播，请参阅*AWS 安全*博客中的[使用可信身份传播 AWS 服务 以编程方式访问](https://aws.amazon.com/blogs//security/access-aws-services-programmatically-using-trusted-identity-propagation/)。

# 设置 Amazon Athena 工作组的可信身份传播
<a name="setting-up-tip-ate"></a>

以下过程将引导您设置 Amazon Athena 工作组以实现可信身份传播。

## 先决条件
<a name="setting-up-tip-ate-prereqs"></a>

在开始本教程之前，您需要设置以下方面：

1. [启用 IAM 身份中心](enable-identity-center.md)。建议使用[组织实例](organization-instances-identity-center.md)。有关更多信息，请参阅 [先决条件和注意事项](trustedidentitypropagation-overall-prerequisites.md)。

1. [将身份源中的用户和组配置到 IAM Identity Center](tutorials.md)。

1. 该配置需要依赖 [Amazon EMR Studio](setting-up-tip-emr.md)、[AWS Lake Formation](tip-tutorial-lf.md) 和 [Amazon S3 访问权限管控](tip-tutorial-s3.md)。

## 设置 Athena 的可信身份传播
<a name="setting-up-tip-ate-step1"></a>

要设置 Athena 的可信身份传播，Athena 管理员必须：

1. 查看[使用已启用 IAM Identity Center 的 Athena 工作组的注意事项和限制](https://docs.aws.amazon.com//athena/latest/ug/workgroups-identity-center.html#workgroups-identity-center-considerations-and-limitations)。

1. [创建启用 IAM Identity Center 的 Athena 工作组](https://docs.aws.amazon.com//athena/latest/ug/workgroups-identity-center.html#workgroups-identity-center-creating-an-identity-center-enabled-athena-workgroup)。

# 使用 Amazon SageMaker Studio 进行可信身份传
<a name="trusted-identity-propagation-usecase-sagemaker-studio"></a>

A@@ [mazon SageMaker Studio](https://docs.aws.amazon.com//sagemaker/latest/dg/studio-updated.html) 与 IAM 身份中心集成，它支持[用户后台会话](user-background-sessions.md)和可信身份传播。用户后台会话允许用户在 SageMaker Studio 上启动长时间运行的作业，而无需在作业运行时保持登录状态。作业将立即在后台运行，并使用启动作业的用户的权限。即使用户关闭计算机、IAM Identity Center 登录会话过期或用户退出 AWS 访问门户，该作业仍可以继续运行。用户后台会话的默认持续时间为 7 天，但您可以指定最长 90 天的持续时间。可信身份传播支持基于用户身份或组成员身份，为 Amazon S3 存储桶等 AWS 资源提供细粒度访问权限。

下图显示了 SageMaker Studio 的可信身份传播配置，可访问存储在 Amazon S3 存储桶中的数据。IAM Identity Center 已启用用户后台会话，这允许 SageMaker Studio 训练作业在后台运行。训练数据的访问控制由 Amazon S3 Access Grants 提供。

![\[Studio 的可信身份传播示意图， SageMaker SageMaker Studio 训练作业在用户后台会话中运行，并访问由 Amazon S3 提供的 Amazon S3 中的训练数据Access Grants。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/sagemaker-studio-s3-user-background-session-training-job-s3-access-grants-diagram.png)


**AWS 托管应用程序**

以下面向客户端的 AWS 托管应用程序支持可信身份传播：
+ [亚马逊 SageMaker Studio](setting-up-trusted-identity-propagation-sagemaker-studio.md)

**如需启用可信身份传播和用户后台会话，请执行以下步骤：**
+ [将 SageMaker Studio 设置为面向客户端的应用程序。](setting-up-trusted-identity-propagation-sagemaker-studio.md)
+ [设置 Amazon S3 Access Grants](tip-tutorial-s3.md)，以便允许临时访问 Amazon S3 中的底层数据位置。

# 使用 SageMaker Studio 设置可信身份传播
<a name="setting-up-trusted-identity-propagation-sagemaker-studio"></a>

以下过程将引导您完成设置 SageMaker Studio 以进行可信身份传播和用户后台会话的过程。

## 先决条件
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-prereqs"></a>

开始本教程之前，您需要完成以下任务：

1. [启用 IAM 身份中心](enable-identity-center.md)。需使用组织实例。有关更多信息，请参阅 [先决条件和注意事项](trustedidentitypropagation-overall-prerequisites.md)。

1. [将身份源中的用户和组配置到 IAM Identity Center](tutorials.md)。

1. 在 IAM Identity Center 控制台中[确认已启用用户后台会话](user-background-sessions.md)。默认情况下，用户后台会话处于启用状态，会话持续时间设置为 7 天。您可以修改此持续时间。

要从 SageMaker Studio 设置可信身份传播， SageMaker Studio 管理员必须执行以下步骤。

## 步骤 1：在新的 Studio 域或现有 SageMaker Studio 域中启用可信身份传播
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-enable-in-domain"></a>

SageMaker Studio 使用域来组织用户个人资料、应用程序及其相关资源。要启用可信身份传播，必须按照以下步骤创建 SageMaker Studio 域或修改现有域。

1. 打开 SageMaker AI 控制台，导航到 “**域**”，然后执行以下任一操作。
   + **使用[组织安装程序](https://docs.aws.amazon.com//sagemaker/latest/dg/onboard-custom.html#onboard-custom-instructions)创建新的 SageMaker Studio 域。**

     选择**为组织设置**，然后执行以下操作：
     + 选择 **AWS Identity Center** 作为身份验证方式。
     + 勾选**为该域上的所有用户启用可信身份传播**复选框。
   + **修改现有的 SageMaker Studio 域名。**
     + 选中使用 IAM Identity Center 进行身份验证的现有域。
**重要**  
仅在使用 IAM 身份中心进行身份验证的 SageMaker Studio 域中支持可信身份传播。如果该域使用 IAM 进行身份验证，则无法更改身份验证方式，因此也无法启用可信身份传播。
     + [编辑域设置](https://docs.aws.amazon.com//sagemaker/latest/dg/domain-edit)。编辑**身份验证和权限**设置，启用可信身份传播。

1. 继续执行[步骤 2：配置默认域执行角色](#setting-up-trusted-identity-propagation-sagemaker-studio-domain-execution-role)。 SageMaker Studio 域的用户需要此角色才能访问其他 AWS 服务，例如 Amazon S3。

## 步骤 2：配置默认域执行角色与角色信任策略
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-domain-execution-role"></a>

*域执行角色*是 SageMaker Studio 域代表网域中所有用户担任的 [IAM 角色](https://docs.aws.amazon.com//IAM/latest/UserGuide/id_roles)。您分配给该角色的权限决定了 SageMaker Studio 可以执行的操作。

1. 要创建或选择域执行角色，请执行以下任一操作：
   + **通过[组织设置](https://docs.aws.amazon.com//sagemaker/latest/dg/onboard-custom.html#onboard-custom-instructions)创建或选择角色。**
     + 打开 SageMaker AI 控制台，按照**步骤 2：配置角色和机器学习活动**中的控制台指南创建新的域执行角色或选择现有角色。
     + 完成其余设置步骤以创建您的 SageMaker Studio 域名。
   + **手动创建执行角色。**
     + 打开 IAM 控制台并[自行创建执行角色](https://docs.aws.amazon.com//sagemaker/latest/dg/sagemaker-roles.html#sagemaker-roles-create-execution-role)。

1. [更新](https://docs.aws.amazon.com//IAM/latest/UserGuide/id_roles_update-role-trust-policy.html)附加到域执行角色的信任策略，使其包含以下两个操作：[https://docs.aws.amazon.com//STS/latest/APIReference/API_AssumeRole.html](https://docs.aws.amazon.com//STS/latest/APIReference/API_AssumeRole.html) 和 [https://docs.aws.amazon.com//IAM/latest/UserGuide/reference_policies_iam-condition-keys.html](https://docs.aws.amazon.com//IAM/latest/UserGuide/reference_policies_iam-condition-keys.html)。有关如何查找 SageMaker Studio 域的执行角色的信息，请参阅[获取域执行角色](https://docs.aws.amazon.com//sagemaker/latest/dg/sagemaker-roles.html#sagemaker-roles-get-execution-role-domain)。

   *信任策略*用于指定可以扮演该角色的身份。此策略是允许 SageMaker Studio 服务担任域执行角色所必需的。添加这两个操作，使其在策略中显示如下。

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

## 步骤 3：验证域执行角色所需的 Amazon S3 访问权限管控权限
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-s3-access-grant-permissions-execution-role"></a>

要使用 Amazon S3 访问授权，您必须将包含以下权限的 SageMaker Studio 域执行角色附加权限策略（内联策略或客户托管策略）。

```
{

    "Version": "2012-10-17", 		 	 	  

    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:GetDataAccess",
                "s3:GetAccessGrantsInstanceForPrefix"
                ],
            "Resource": "arn:aws:s3:us-east-2:111122223333:access-grants/default"
        }
    ]
}
```

如果您暂无包含这些权限的策略，请参阅《*AWS Identity and Access Management 用户指南*》中的[添加和移除 IAM 身份权限](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_manage-attach-detach.html)。

## 步骤 4：为域分配组和用户
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-assign-users-groups-to-domain"></a>

按照[添加群组和用户中的步骤将群组和用户](https://docs.aws.amazon.com//sagemaker/latest/dg/domain-groups-add.html)分配到 SageMaker Studio 域。

## 步骤 5：设置 Amazon S3 访问权限管控
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-set-up-s3-access-grants"></a>

要设置 Amazon S3 访问权限管控，请遵循[通过 IAM Identity Center 配置可信身份传播的 Amazon S3 访问权限管控](tip-tutorial-s3.md#tip-tutorial-s3-configure)中的步骤。按照 step-by-step说明完成以下任务：

1. 创建 Amazon S3 访问权限管控实例。

1. 在该实例中注册位置。

1. 创建授权，允许特定 IAM Identity Center 用户或组访问指定的 Amazon S3 位置或这些位置内的子集（例如特定前缀）。

## 第 6 步：提交 SageMaker 训练作业并查看用户后台会话详情
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-submit-training-job-view-user-background-session-details"></a>

在 SageMaker Studio 中，启动一台新的 Jupyter 笔记本并提交一份训练作业。作业运行期间，完成以下步骤以查看会话信息并验证用户后台会话上下文是否处于活跃状态。

1. 打开 IAM Identity Center 控制台。

1. 选择**用户**。

1. 在**用户**页面上，选择要管理其会话的用户的用户名。这会让您转至包含用户信息的页面。

1. 在用户页面上，选择**活跃会话**选项卡。**活跃会话**旁边括号中的数字表示该用户处于活跃状态的会话数。

1. 要按使用该会话的作业的 Amazon 资源名称（ARN）搜索会话，请在**会话类型**列表中选择**用户后台会话**，然后在搜索框中输入作业 ARN。

以下示例展示了使用用户后台会话的训练作业在用户的**活跃会话**选项卡中的显示形式。

![\[alt text not found\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/sagemaker-studio-training-job-displayed-in-identity-center-console-active-sessions.png)


## 步骤 7：查看 CloudTrail 日志以验证可信身份的传播 CloudTrail
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-view-cloudtrail-logs"></a>

启用可信身份传播后，操作会显示在`onBehalfOf`元素下方 CloudTrail 的事件日志中。`userId` 字段将显示启动训练作业的 IAM Identity Center 用户的 ID。以下 CloudTrail 事件捕获了可信身份传播的过程。

```
                            "userIdentity": {
    "type": "AssumedRole",
    "principalId": "AROA123456789EXAMPLE:SageMaker",
    "arn": "arn:aws:sts::111122223333:assumed-role/SageMaker-ExecutionRole-20250728T125817/SageMaker",
    "accountId": "111122223333",
    "accessKeyId": "ASIAIOSFODNN7EXAMPLE",
    "sessionContext": {
        "sessionIssuer": {
            "type": "Role",
            "principalId": "AROA123456789EXAMPLE",
            "arn": "arn:aws:iam::111122223333:role/service-role/SageMaker-ExecutionRole-20250728T125817",
            "accountId": "111122223333",
            "userName": "SageMaker-ExecutionRole-20250728T125817"
        },
        "attributes": {
            "creationDate": "2025-07-29T17:17:10Z",
            "mfaAuthenticated": "false"
        }
    },
    "onBehalfOf": {
        "userId": "2801d3e0-f0e1-707f-54e8-f558b19f0a10",
        "identityStoreArn": "arn:aws:identitystore::777788889999:identitystore/d-1234567890"
    }
},
```

## 运行时系统注意事项
<a name="setting-up-trusted-identity-propagation-sagemaker-ai-runtime-considerations"></a>

如果管理员将长时间运行的训练或处理作业设置**MaxRuntimeInSeconds**为低于用户后台会话持续时间， SageMaker Studio 会运行该作业的时间至少为用户后台会话持续时间中的一个**MaxRuntimeInSeconds **或一个。

有关更多信息 **MaxRuntimeInSeconds**，请参阅 *Amazon SageMaker API 参考*中的`CreateTrainingJob`[StoppingCondition](https://docs.aws.amazon.com//sagemaker/latest/APIReference/API_CreateTrainingJob.html#sagemaker-CreateTrainingJob-request-StoppingCondition)参数指南。

# 授权服务
<a name="authorization-services"></a>

在所有[分析和数据湖仓使用案例](trustedidentitypropagation-integrations.md#tip-data-analytic-usecases-overview)中，您可以通过以下服务实现细粒度访问控制：
+ AWS Lake Formation -有关指导，请参阅[AWS Lake Formation 使用 IAM 身份中心进行设置](tip-tutorial-lf.md)。
+ Amazon S3 Access Grants - 有关指导，请参阅 [使用 IAM Identity Center 设置 Amazon S3 访问权限管控](tip-tutorial-s3.md)。

# AWS Lake Formation 使用 IAM 身份中心进行设置
<a name="tip-tutorial-lf"></a>

[AWS Lake Formation](https://docs.aws.amazon.com//lake-formation/latest/dg/what-is-lake-formation.html) 是一项托管服务，可简化 AWS上数据湖的创建和管理。它可自动化数据收集、编目和安全配置，为存储和分析多种数据类型提供集中式存储库。Lake Formation 提供精细的访问控制并与各种 AWS 分析服务集成，使组织能够高效地设置、保护数据湖并从中获取见解。

按照以下步骤配置 Lake Formation，使其能够通过 IAM Identity Center 和可信身份传播，基于用户身份授予数据权限。

## 先决条件
<a name="tip-tutorial-lf-prereqs"></a>

在开始本教程之前，您需要设置以下方面：
+ [启用 IAM 身份中心](enable-identity-center.md)。建议使用[组织实例](organization-instances-identity-center.md)。有关更多信息，请参阅 [先决条件和注意事项](trustedidentitypropagation-overall-prerequisites.md)。

## 设置可信身份传播的步骤
<a name="tip-tutorial-lf-step1"></a>

1. **集成 IAM Identity Center 与 AWS Lake Formation**，请遵循[将 Lake Formation 与 IAM Identity Center 连接](https://docs.aws.amazon.com//lake-formation/latest/dg/connect-lf-identity-center.html)中的指引。
**重要**  
**如果您暂无 AWS Glue Data Catalog 表**，则必须创建这些表才能通过 AWS Lake Formation 向 IAM Identity Center 用户和组授予访问权限。有关更多信息，请参阅[在 AWS Glue Data Catalog中创建对象](https://docs.aws.amazon.com//lake-formation/latest/dg/populating-catalog.html)。

1. **注册数据湖位置**。

   [注册 Glue 表数据所在的 S3 位置](https://docs.aws.amazon.com//lake-formation/latest/dg/register-location.html)。这样，Lake Formation 将在查询表时提供对所需 S3 位置的临时访问权限，从而无需在服务角色中包含 S3 权限（例如，上配置的 Athena 服务角色）。 WorkGroup

   1. 导航到 AWS Lake Formation 控制台导航窗格中 “**管理**” 部分下的**数据湖位置**。选择**注册位置**。

      这将允许 Lake Formation 生成具有访问 S3 数据位置所需权限的临时 IAM 凭据。  
![\[步骤 1：在 Lake Formation 控制台注册数据湖位置。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/lf-tutorial-step-3.1.png)

   1. 在 **Amazon S3 路径**字段中，输入 AWS Glue 表数据位置的 S3 路径。

   1. 在 **IAM 角色**部分，如果要配合可信身份传播使用，请不要选择服务关联角色。创建具有以下权限的单独角色。

      要使用这些政策，请用您自己的信息替换示例*italicized placeholder text*中的策略。有关详细操作指引，请参阅[创建策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_create.html)或[编辑策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_manage-edit.html)。权限策略应授予对路径中指定的 S3 位置的访问权限：

      1. **权限策略**：

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

****  

         ```
         {
             "Version":"2012-10-17",		 	 	 
             "Statement": [
                 {
                     "Sid": "LakeFormationDataAccessPermissionsForS3",
                     "Effect": "Allow",
                     "Action": [
                         "s3:PutObject",
                         "s3:GetObject",
                         "s3:DeleteObject"
                     ],
                     "Resource": [
                         "arn:aws:s3:::Your-S3-Bucket/*"
                     ]
                 },
                 {
                     "Sid": "LakeFormationDataAccessPermissionsForS3ListBucket",
                     "Effect": "Allow",
                     "Action": [
                         "s3:ListBucket"
                     ],
                     "Resource": [
                         "arn:aws:s3:::Your-S3-Bucket"
                     ]
                 },
                 {
                     "Sid": "LakeFormationDataAccessServiceRolePolicy",
                     "Effect": "Allow",
                     "Action": [
                         "s3:ListAllMyBuckets"
                     ],
                     "Resource": [
                         "arn:aws:s3:::*"
                     ]
                 }
             ]
         }
         ```

------

      1. **信任关系**：应包含 `sts:SectContext`（可信身份传播的必需操作）。

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

****  

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

------
**注意**  
向导创建的 IAM 角色为服务关联角色，不包含 `sts:SetContext` 操作权限。

   1. 创建 IAM 角色后，选择**注册位置**。

## 使用 Lake Formation 进行可信身份传播 AWS 账户
<a name="tip-lf-across-accts"></a>

AWS Lake Formation 支持使用 [AWS Resource Access Manager (RAM)](https://docs.aws.amazon.com//ram/latest/userguide/what-is.html) 共享表，当授予者账户 AWS 账户 和被授权者账户处于相同 AWS 区域、相同且共享相同的 IAM Identity Center 组织实例时 AWS Organizations，它可以进行可信身份传播。有关更多信息，请参阅 [Lake Formation 中的跨账户数据共享](https://docs.aws.amazon.com//lake-formation/latest/dg/cross-data-sharing-lf.html)。

# 使用 IAM Identity Center 设置 Amazon S3 访问权限管控
<a name="tip-tutorial-s3"></a>

[Amazon S3 Access Grants](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-get-started.html) 提供灵活的基于身份的细粒度访问控制能力，可用于授权访问 S3 位置。您可以通过 Amazon S3 Access Grants，直接向企业用户和组授予 Amazon S3 存储桶的访问权限。按照以下步骤启用 S3 Access Grants 与 IAM Identity Center 的集成，实现可信身份传播。

## 先决条件
<a name="tip-tutorial-s3-prereqs"></a>

在开始本教程之前，您需要设置以下方面：
+ [启用 IAM 身份中心](enable-identity-center.md)。建议使用[组织实例](organization-instances-identity-center.md)。有关更多信息，请参阅 [先决条件和注意事项](trustedidentitypropagation-overall-prerequisites.md)。

## 通过 IAM Identity Center 配置可信身份传播的 S3 访问权限管控
<a name="tip-tutorial-s3-configure"></a>

**如果您已创建 Amazon S3 Access Grants 实例且已注册位置，请执行以下步骤：**

1. [关联您的 IAM Identity Center 实例](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-instance-idc.html)。

1. [创建授权](#tip-tutorial-s3-create-grant)。

**如果您尚未创建 Amazon S3 Access Grants，请执行以下步骤：**

1. [https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-instance-create.html](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-instance-create.html)-您可以为每个Access Grants实例创建一个 S3 实例 AWS 区域。创建 S3 Access Grants 实例时，请务必勾选**添加 IAM Identity Center 实例**选项框，并提供您的 IAM Identity Center 实例 ARN。选择**下一步**。

   下图展示了 Amazon S3 Access Grants 控制台中的“创建 S3 Access Grants 实例”页面：  
![\[S3 访问权限管控控制台的“创建 S3 Access Grants 实例”页面。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/s3-tutorial-step-1.1.png)

1. **注册营业地点**-在您的账户中[创建 Amazon S3 Access Grants 实例](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-instance-create.html)后，您就可以在该实例中[注册一个 S3 地点](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-location-register.html)。 AWS 区域 S3 Access Grants 位置会将默认 S3 区域（`S3://`）、存储桶或前缀映射到某个 IAM 角色。S3 Access Grants 代入此 Amazon S3 角色，来向正在访问该特定位置的被授权者提供临时凭证。您必须先在 S3 Access Grants 实例中注册至少一个位置，然后才能创建访问权限管控。

   对于**位置范围**，请指定 `s3://`，其中包含该区域内的所有存储桶。这是大多数使用案例的推荐位置范围。如果您有高级访问管理使用案例，可将位置范围设置为特定存储桶 `s3://bucket` 或存储桶内的前缀 `s3://bucket/prefix-with-path`。有关更多信息，请参阅*《Amazon Simple Storage Service 用户指南》*中的[注册位置](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-location-register.html)。
**注意**  
确保您要授予访问权限的 AWS Glue 表的 S3 位置包含在此路径中。

   该过程要求您为该位置配置 IAM 角色。该角色应包含访问该位置范围的权限。您可以通过 S3 控制台向导创建该角色。您需要在该 IAM 角色的策略中指定您的 S3 Access Grants 实例 ARN。您的 S3 Access Grants 实例 ARN 的默认值为 `arn:aws:s3:Your-Region:Your-AWS-Account-ID:access-grants/default`。

   以下权限策略示例为您创建的 IAM 角色授予 Amazon S3 权限。后续的信任策略示例允许 S3 Access Grants 服务主体扮演该 IAM 角色。

   1. **权限策略**

      要使用这些政策，请用您自己的信息替换示例*italicized placeholder text*中的策略。有关详细操作指引，请参阅[创建策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_create.html)或[编辑策略](https://docs.aws.amazon.com//IAM/latest/UserGuide/access_policies_manage-edit.html)。

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

****  

      ```
      {
          "Version":"2012-10-17",		 	 	 
          "Statement": [
              {
                  "Sid": "ObjectLevelReadPermissions",
                  "Effect": "Allow",
                  "Action": [
                      "s3:GetObject",
                      "s3:GetObjectVersion",
                      "s3:GetObjectAcl",
                      "s3:GetObjectVersionAcl",
                      "s3:ListMultipartUploadParts"
                  ],
                  "Resource": [
                      "arn:aws:s3:::*"
                  ],
                  "Condition": {
                      "StringEquals": {
                          "aws:ResourceAccount": "111122223333"
                      },
                      "ArnEquals": {
                          "s3:AccessGrantsInstanceArn": [
                          "arn:aws:s3:::access-grants/instance-id"
                          ]
                      }
                  }
              },
              {
                  "Sid": "ObjectLevelWritePermissions",
                  "Effect": "Allow",
                  "Action": [
                      "s3:PutObject",
                      "s3:PutObjectAcl",
                      "s3:PutObjectVersionAcl",
                      "s3:DeleteObject",
                      "s3:DeleteObjectVersion",
                      "s3:AbortMultipartUpload"
                  ],
                  "Resource": [
                      "arn:aws:s3:::*"
                  ],
                  "Condition": {
                      "StringEquals": {
                      "aws:ResourceAccount": "111122223333"
                      },
                      "ArnEquals": {
                          "s3:AccessGrantsInstanceArn": [
                          "arn:aws:s3:::access-grants/instance-id"
                          ]
                      }
                  }
              },
              {
                  "Sid": "BucketLevelReadPermissions",
                  "Effect": "Allow",
                  "Action": [
                      "s3:ListBucket"
                  ],
                  "Resource": [
                      "arn:aws:s3:::*"
                  ],
                  "Condition": {
                      "StringEquals": {
                      "aws:ResourceAccount": "111122223333"
                      },
                      "ArnEquals": {
                          "s3:AccessGrantsInstanceArn": [
                          "arn:aws:s3:::access-grants/instance-id"
                          ]
                      }
                  }
              },
              {
                  "Sid": "OptionalKMSPermissionsForSSEEncryption",
                  "Effect": "Allow",
                  "Action": [
                      "kms:Decrypt",
                      "kms:GenerateDataKey"
                  ],
                  "Resource": [
                      "*"
                  ]
              }
          ]
      }
      ```

------

   1. **信任策略**

       在 IAM 角色信任策略中，向 S3 访问权限管控服务 (`access-grants.s3.amazonaws.com`)主体授予对您创建的 IAM 角色的访问权限。为此，您可以创建一个包含以下语句的 JSON 文件。要将信任策略添加到您的账户，请参阅[使用自定义信任策略创建角色](https://docs.aws.amazon.com//IAM/latest/UserGuide/id_roles_create_for-custom.html)。

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

****  

      ```
      {
          "Version":"2012-10-17",		 	 	 
          "Statement": [
              {
                  "Sid": "Stmt1234567891011",
                  "Effect": "Allow",
                  "Action": [
                      "sts:AssumeRole",
                      "sts:SetSourceIdentity"
                  ],
                  "Resource": "*",
                  "Condition": {
                      "StringEquals": {
                          "aws:SourceAccount": "111122223333",
                          "aws:SourceArn": "Your-Custom-Access-Grants-Location-ARN"
                      }
                  }
              },
      
              {
                  "Sid": "Stmt1234567891012",
                  "Effect": "Allow",
                  "Action": "sts:SetContext",
                  "Resource": "*",
                  "Condition": {
                      "StringEquals": {
                          "aws:SourceAccount": "111122223333",
                          "aws:SourceArn": "Your-Custom-Access-Grants-Location-ARN"
                      },
                      "ForAllValues:ArnEquals": {
                          "sts:RequestContextProviders": "arn:aws:iam::aws:contextProvider/IdentityCenter"
                      }
                  }
              }
          ]
      }
      ```

------

## 创建 Amazon S3 访问权限管控
<a name="tip-tutorial-s3-create-grant"></a>

如果您已创建带有已注册位置的 Amazon S3 Access Grants 实例，且已关联 IAM Identity Center 实例，则可以[创建授权](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-grant-create.html)。在 S3 控制台的**创建授权**页面，完成以下操作：

**创建授权**

1. 选择上一步创建的位置。您可以通过添加子前缀缩小授权范围。子前缀可以是 `bucket`、`bucket/prefix` 或存储桶中的对象。有关更多信息，请参阅《*Amazon Simple Storage Service 用户指南*》中的[子前缀](https://docs.aws.amazon.com//AmazonS3/latest/userguide/access-grants-grant-create.html#subprefix)。

1. 在**权限和访问**下，根据需求选择**读取**和/或**写入**。

1. 在**授权方类型**中，选择**来自 IAM Identity Center 的目录身份**。

1. 提供 IAM Identity Center **用户或组 ID**。您可以在 IAM Identity Center 控制台的 “用户和群组 IDs ” [部分下找到该**用户**和**群组**](howtoviewandchangepermissionset.md)。选择**下一步**。

1. 在**审核并完成**页面，确认 S3 Access Grant 的设置，然后选择**创建授权**。

   下图展示了 Amazon S3 Access Grants 控制台中的“创建授权”页面：  
![\[Amazon S3 访问权限管控控制台的“创建授权”页面。\]](http://docs.aws.amazon.com/zh_cn/singlesignon/latest/userguide/images/s3-tutorial-step-1.4.png)