

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

# 信任的身分傳播概觀
<a name="trustedidentitypropagation-overview"></a>

信任的身分傳播是 IAM Identity Center 的一項功能，可讓 的管理員根據 群組關聯等使用者屬性 AWS 服務 授予許可。透過信任的身分傳播，身分內容會新增至 IAM 角色，以識別請求存取 AWS 資源的使用者。此內容會傳播到其他內容 AWS 服務。

身分內容包含的資訊， AWS 服務 用於在收到存取請求時做出授權決策。此資訊包含識別請求者的中繼資料 （例如 IAM Identity Center 使用者）、請求存取的 AWS 服務 （例如 Amazon Redshift)，以及存取範圍 （例如唯讀存取）。接收 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. **將 的使用案例中 AWS 服務 的 連接到 IAM Identity Center** - AWS 服務 信任的身分傳播使用案例中每個 的管理員遵循個別服務文件中的指引，將服務連接到 IAM Identity Center。

**注意**  
如果您的使用案例涉及*第三方*或*客戶開發的應用程式*，您可以在驗證應用程式使用者和 IAM Identity Center 的身分提供者之間設定信任關係，以啟用信任的身分傳播。這可讓您的應用程式利用先前描述的信任身分傳播流程。  
如需詳細資訊，請參閱[使用具有受信任權杖發行者的應用程式](using-apps-with-trusted-token-issuer.md)。

## 受信任身分傳播的運作方式
<a name="how-tip-works"></a>

下圖顯示受信任身分傳播的高階工作流程：

![\[簡化的受信任身分傳播工作流程。\]](http://docs.aws.amazon.com/zh_tw/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_tw/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 Organization 執行個體 - 我們建議您使用在 管理帳戶中啟用的 IAM Identity Center [組織執行個體](organization-instances-identity-center.md) AWS Organizations。您可以將 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 Identity Center。

## 考量事項
<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 Identity Center 搭配使用的 受管應用程式](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 Identity Center](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>

您可以使用這些額外的 啟用 IAM Identity Center 和信任的身分傳播 AWS 服務：
+ **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 Service** - 如需指引，請參閱：
  + [Amazon OpenSearch Service 的 IAM Identity Center Trusted Identity Propagation Support](https://docs.aws.amazon.com//opensearch-service/latest/developerguide/idc-aos.html)。
  + [使用 Amazon OpenSearch Service 的集中式 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 受管或外部 AWS - 使用 Amazon Redshift 或授權服務，例如 AWS Lake Formation 或 Amazon S3 提供的存取控制來查詢 Amazon Redshift 資料Access Grants。

![\[使用 Amazon Redshift、Quick、Lake Formation 和 IAM Identity Center 的受信任身分傳播圖表\]](http://docs.aws.amazon.com/zh_tw/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 Redshift Query 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 Identity Center](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. 下列政策範例包含完成本教學課程所需的許可。若要使用此政策，請將範例政策中的*斜體預留位置文字*取代為您自己的資訊。如需其他指示，請參閱[建立政策](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. 在 AWS Organizations 啟用 IAM Identity Center 的管理帳戶中**建立許可集**。您將在下一個步驟中使用它，以允許聯合身分使用者存取 Redshift 查詢編輯器 V2。

   1. 前往 **IAM Identity Center** 主控台，在**多帳戶許可**下，選擇**許可集**。

   1. 選擇 **Create permission set (建立許可集合)**。

   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 Dashboard，然後從**設定摘要**區段複製 AWS 存取入口網站 URL。  
![\[步驟 i，從 IAM Identity Center 主控台複製 AWS 存取入口網站 URL。\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/setting-up-redshift-step-i.png)

   1. 開啟新的 Incognito 瀏覽器視窗並貼上 URL。

      這將帶您前往 AWS 存取入口網站，確保您使用 IAM Identity Center 使用者登入。  
![\[步驟 j：登入以 AWS 存取入口網站。\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/setting-up-redshift-step-j.png)

      如需許可集的詳細資訊，請參閱 [AWS 帳戶 使用許可集管理](permissionsetsconcept.md)。

1. **啟用聯合身分使用者存取 Redshift 查詢編輯器 V2**。

   1. 在 AWS Organizations 管理帳戶中，開啟 **IAM Identity Center** 主控台。

   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 大數據部落格*中的[整合身分提供者 (IdP) 與使用 IAM Identity Center 的 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 on Amazon EC2 搭配 AWS Lake Formation 和 Amazon S3 提供之存取控制的 Amazon EMR Studio 的受信任身分傳播組態Access Grants。

![\[使用 Amazon EMR、Lake Formation 和 IAM Identity Center 的受信任身分傳播圖表\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/emr-tip-diagram.png)


**支援面向用戶端的應用程式**
+ Amazon EMR Studio

**若要啟用信任的身分傳播，請遵循下列步驟：**
+ [將 Amazon EMR 設定為 Studio](setting-up-tip-emr.md) Amazon EMR 叢集的面向用戶端應用程式。
+ [使用 在 Amazon EC2 上設定 Amazon EMR 叢集Apache Spark](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 Athena 工作群組或 Amazon EMR 叢集的查詢中設定 Amazon EMR Studio以進行受信任身分傳播Apache Spark。

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

您必須先設定下列項目，才能開始使用本教學課程：

1. [啟用 IAM Identity Center](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管理員會建立 和 IAM 服務角色，以及 EMR 的 IAM 使用者角色Studio。

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**。連接下列政策以定義角色的許可和信任關係。

      若要使用這些政策，請以您自己的資訊取代範例政策中的*斜體預留位置文字*。如需其他指示，請參閱[建立政策](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 Catalog. AWS Lake Formation permissions 中資料表 Amazon S3 位置的許可。註冊的湖位置將用於接收臨時許可。

   下列範例政策可用於允許 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 Workspaces 和 EMR Notebooks。如需詳細資訊，請參閱[建立 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，並使用您在 中建立的 IAM 角色[步驟 1. 建立 EMR Studio 所需的 IAM 角色步驟 2. 建立和設定 EMR Studio](#setting-up-tip-emr-step1)。

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_tw/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_tw/singlesignon/latest/userguide/images/emr-tutorial-step-3.3.png)

1. 勾選**信任的身分傳播**方塊。在應用程式存取區段下選擇**僅指派的使用者和群組**，這可讓您僅授予授權的使用者和群組存取此 Studio。

1. *（選用）* - 如果您搭配 EMR 叢集使用此 Studio，則可以設定 VPC 和子網路。  
![\[步驟 4 在 EMR 主控台中建立 EMR Studio，選取網路和安全性設定。\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/emr-tutorial-step-3.4.png)

1. 檢閱所有詳細資訊，然後選取**建立 Studio**。

1. 設定 Athena WorkGroup 或 EMR 叢集之後，請登入 Studio 的 URL 以：

   1. 使用查詢編輯器執行 Athena 查詢。

   1. 使用Jupyter筆記本在工作區中執行 Spark 任務。

# 使用 Amazon Athena 的受信任身分傳播
<a name="tip-usecase-ate"></a>

啟用受信任身分傳播的步驟取決於您的使用者是否與 AWS 受管應用程式或客戶受管應用程式互動。下圖顯示用戶端應用程式可信任的身分傳播組態 - AWS 受管或外部 AWS - 使用 Amazon Athena 透過 AWS Lake Formation 和 Amazon S3 提供的存取控制來查詢 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_tw/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 中基礎資料位置的暫時存取。

**注意**  
Amazon S3 中對 Athena 查詢結果的存取控制Access Grants需要 Lake Formation AWS Glue Data Catalog 和 Amazon S3。

**客戶受管應用程式**  
若要為*自訂開發應用程式*的使用者啟用受信任身分傳播，請參閱 *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 Identity Center](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 Access Grants](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>

[Amazon SageMaker Studio](https://docs.aws.amazon.com//sagemaker/latest/dg/studio-updated.html) 與 IAM Identity Center 整合，並支援[使用者背景工作階段](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。

![\[SageMaker Studio 的受信任身分傳播圖表，以及在使用者背景工作階段中執行的 SageMaker Studio 訓練任務，以及存取 Amazon S3 提供之 Amazon S3 中的訓練資料Access Grants。\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/sagemaker-studio-s3-user-background-session-training-job-s3-access-grants-diagram.png)


**AWS 受管應用程式**

下列 AWS 受管用戶端面向應用程式支援受信任的身分傳播：
+ [Amazon 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 Identity Center](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：在新的或現有的 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 Identity Center 進行身分驗證的 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：設定角色和 ML 活動**中的主控台指引，以建立新的網域執行角色或選取現有角色。
     + 完成其餘的設定步驟，以建立 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 Access Grant 許可
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-s3-access-grant-permissions-execution-role"></a>

若要使用 Amazon S3 Access Grants，您必須將許可政策 （做為內嵌政策或客戶受管政策） 連接至包含下列許可的 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 Access Grants
<a name="setting-up-trusted-identity-propagation-sagemaker-studio-set-up-s3-access-grants"></a>

若要設定 Amazon S3 Access Grants，請遵循[透過 IAM Identity Center 為受信任身分傳播設定 Amazon S3 Access Grants ](tip-tutorial-s3.md#tip-tutorial-s3-configure)中的步驟。使用step-by-step說明來完成下列任務：

1. 建立 Amazon S3 Access Grants 執行個體。

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. 選擇 **Users** (使用者)。

1. 在**使用者**頁面上，選擇您要管理其工作階段的使用者名稱。這會帶您前往包含使用者資訊的頁面。

1. 在使用者頁面上，選擇**作用中工作階段**索引標籤。**作用中工作階段**旁的括號中的數字表示此使用者的作用中工作階段數量。

1. 若要依使用工作階段之任務的 Amazon Resource Name (ARN) 搜尋工作階段，請在**工作階段類型**清單中，選擇**使用者背景工作階段**，然後在搜尋方塊中輸入任務 ARN。

以下是使用使用者背景工作階段的訓練任務如何在使用者的 **Active 工作階段**索引標籤中顯示的範例。

![\[alt text not found\]](http://docs.aws.amazon.com/zh_tw/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 Identity Center 設定](tip-tutorial-lf.md)。
+ Amazon S3 Access Grants - 如需指引，請參閱 [使用 IAM Identity Center 設定 Amazon S3 Access Grants](tip-tutorial-s3.md)。

# AWS Lake Formation 使用 IAM Identity Center 設定
<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 分析服務整合，讓組織能夠有效率地設定、保護並從其資料湖衍生洞見。

請依照下列步驟，使用 IAM Identity Center 和信任的身分傳播，讓 Lake Formation 根據使用者身分授予資料許可。

## 先決條件
<a name="tip-tutorial-lf-prereqs"></a>

您必須先設定下列項目，才能開始使用本教學課程：
+ [啟用 IAM Identity Center](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 位置的臨時存取權，因此不需要在服務角色 （例如 WorkGroup 上設定的 Athena 服務角色） 中包含 S3 許可。

   1. 在 AWS Lake Formation 主控台的導覽窗格中，導覽至**管理**區段下方的**資料湖位置**。選取**註冊位置**。

      這將允許 Lake Formation 佈建具有存取 S3 資料位置必要許可的臨時 IAM 登入資料。  
![\[步驟 1 在 Lake Formation 主控台中註冊資料湖位置。\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/lf-tutorial-step-3.1.png)

   1. 在 Amazon S3 路徑欄位中輸入資料表資料位置的 AWS Glue S3 路徑。 **Amazon S3 ** 

   1. 在 **IAM 角色**區段中，如果您想要將服務連結角色與信任的身分傳播搭配使用，請勿選取該角色。建立具有下列許可的個別角色。

      若要使用這些政策，請以您自己的資訊取代範例政策中的*斜體預留位置文字*。如需其他指示，請參閱[建立政策](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 Access Grants
<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 儲存貯體存取權直接授予公司使用者和群組。請依照下列步驟，Access Grants透過 IAM Identity Center 啟用 S3，並實現受信任的身分傳播。

## 先決條件
<a name="tip-tutorial-s3-prereqs"></a>

您必須先設定下列項目，才能開始使用本教學課程：
+ [啟用 IAM Identity Center](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)。

**如果您Access Grants尚未建立 Amazon S3，請遵循下列步驟：**

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) - 您可以為每個執行個體建立一個 S3 Access Grants執行個體 AWS 區域。當您建立 S3 Access Grants執行個體時，請務必勾選**新增 IAM Identity Center 執行個體**方塊，並提供 IAM Identity Center 執行個體的 ARN。選取**下一步**。

   下圖顯示 Amazon S3 Access Grants主控台中的建立 S3 Access Grants執行個體頁面： Amazon S3   
![\[在 S3 Access Grants 主控台中建立 S3 Access Grants執行個體頁面。\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/s3-tutorial-step-1.1.png)

1. **註冊位置** - 在 AWS 區域 帳戶中的 中[建立 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)。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`。

   下列範例許可政策會將 Amazon S3 許可授予您建立的 IAM 角色。之後的範例信任政策允許 S3 Access Grants服務主體擔任 IAM 角色。

   1. **許可政策**

      若要使用這些政策，請以您自己的資訊取代範例政策中的*斜體預留位置文字*。如需其他指示，請參閱[建立政策](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 使用者指南*》中的 [Subprefix](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 主控台的使用者和群組[區段下找到**使用者**和**群組**](howtoviewandchangepermissionset.md) IDs。選取**下一步**。

1. 在**檢閱和完成**頁面上，檢閱 S3 的設定，Access Grant然後選取**建立授予**。

   下圖顯示 Amazon S3 Access Grants主控台中的建立授予頁面：  
![\[在 Amazon S3 Access Grants 主控台中建立授予頁面。\]](http://docs.aws.amazon.com/zh_tw/singlesignon/latest/userguide/images/s3-tutorial-step-1.4.png)