

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

# 受信任的身分傳播
<a name="security-iam-service-trusted-prop"></a>

透過 Amazon EMR 7.8.0 版及更高版本，您可以透過 Apache Livy 端點使用 EMR Serverless 將使用者身分從 AWS IAM Identity Center 傳播到互動式工作負載。Apache Livy 互動式工作負載將進一步將提供的身分傳播到下游服務，例如 Amazon S3、Lake Formation 和 Amazon Redshift，透過這些下游的使用者身分啟用安全的資料存取。下列各節提供透過 Apache Livy 端點使用 EMR Serverless 啟動和傳播身分至互動式工作負載所需的概念概觀、先決條件和步驟。

## 概觀
<a name="security-iam-service-trusted-prop-overview"></a>

對於任何大小和類型的組織 AWS ，[IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/what-is.html) 是建議在 上進行人力資源身分驗證和授權的方法。使用 Identity Center，在 中建立和管理使用者身分 AWS，或連接現有的身分來源，包括 Microsoft Active Directory、Okta、Ping Identity、JumpCloud、Google Workspace 和 Microsoft Entra ID （先前稱為 Azure AD)。

[信任的身分傳播](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overview.html)是一種 AWS IAM Identity Center 功能，連線 AWS 服務的管理員可以使用此功能來授予和稽核服務資料的存取權。存取此資料是根據使用者屬性，例如群組關聯。設定信任的身分傳播需要連線 AWS 服務的管理員與 IAM Identity Center 管理員之間的協同合作。如需詳細資訊，請參閱《*IAM Identity Center 使用者指南*》中的[先決條件和考量](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overall-prerequisites.html)事項。

## 功能和優勢
<a name="security-iam-service-trusted-prop-features"></a>

EMR Serverless Apache Livy 端點與 IAM Identity Center [受信任身分傳播](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overview.html)整合可提供下列優點：
+ 能夠在 AWS Lake Formation 受管 Glue AWS 資料目錄資料表上使用 Identity Center 身分強制執行資料表層級授權。
+ 能夠在 Amazon Redshift 叢集上使用 Identity Center 身分強制執行授權。
+ 啟用使用者動作的端對端追蹤以進行稽核。
+ 能夠在 S3 Access Grants 受管 S3 字首上使用 Identity Center 身分，強制執行 Amazon S3 字首層級授權。

## 運作方式
<a name="security-iam-service-trusted-prop-features-works"></a>

![\[EMR Serverless 流程圖。\]](http://docs.aws.amazon.com/zh_tw/emr/latest/EMR-Serverless-UserGuide/images/PEZ-SMAI.png)


### 使用案例範例
<a name="security-iam-service-trusted-prop-use-cases"></a>

#### 資料準備與特徵工程
<a name="security-iam-service-trusted-prop-feature-eng"></a>

來自多個研究團隊的資料科學家使用統一的資料平台來協作處理複雜的專案。他們使用其公司登入資料登入 SageMaker AI，立即存取跨越多個 AWS 帳戶的大量共用資料湖。當他們開始為新的機器學習模型進行特徵工程時，透過 EMR Serverless 啟動的 Spark 工作階段會根據其傳播的身分強制執行 Lake Formation 的資料欄和資料列層級安全政策。科學家可以使用熟悉的工具有效率地準備資料和設計功能，而合規團隊可以確保每次資料互動都會自動追蹤和稽核。這個安全、協作的環境可加速研究管道，同時維持受監管產業所需的嚴格資料保護標準。

# Trusted-Identity 傳播入門
<a name="security-iam-service-trusted-prop-getting-started"></a>

本節可協助您使用 Apache Livy 端點設定 EMR-Serverless 應用程式，以與 AWS IAM Identity Center 整合，並啟用[受信任身分傳播](https://docs.aws.amazon.com/singlesignon/latest/userguide/trustedidentitypropagation-overview.html)。

## 先決條件
<a name="security-iam-service-trusted-prop-prereqs"></a>
+ 您要在 AWS 區域中建立啟用受信任身分傳播的 EMR Serverless Apache Livy 端點的 Identity Center 執行個體。Identity Center 執行個體只能存在於 AWS 帳戶的單一區域中。請參閱[啟用 IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/enable-identity-center.html) [和將身分來源中的使用者和群組佈建到 IAM Identity Center](https://docs.aws.amazon.com/singlesignon/latest/userguide/tutorials.html)。
+ 為 Lake Formation 或 S3 Access Grants 或 Amazon Redshift 叢集等下游服務啟用受信任身分傳播，互動式工作負載會與之互動以存取資料。

## 建立啟用信任身分傳播的 EMR Serverless 應用程式的許可
<a name="security-iam-service-trusted-prop-emrs-application"></a>

除了[存取 EMR Serverless 所需的基本許可](setting-up.html#setting-up-iam)之外，您還必須為 IAM 身分或角色設定其他許可，用於建立啟用受信任身分傳播的 EMR Serverless 應用程式。對於受信任身分傳播，EMR Serverless 會在您的帳戶中建立/引導單一服務受管身分中心應用程式，該應用程式會利用該應用程式將身分驗證和身分傳播到下游。

```
"sso:DescribeInstance",
"sso:CreateApplication", 
"sso:DeleteApplication",
"sso:PutApplicationAuthenticationMethod",
"sso:PutApplicationAssignmentConfiguration",  
"sso:PutApplicationGrant", 
"sso:PutApplicationAccessScope"
```
+ `sso:DescribeInstance` – 准許描述和驗證您在 identity-center-configuration 參數中指定的 IAM Identity Center instanceArn。
+ `sso:CreateApplication` – 准許建立用於trusted-identity-propatgion Center 應用程式。
+ `sso:DeleteApplication` – 准許清除 EMR Serverless 受管 IAM Identity Center 應用程式
+ `sso:PutApplicationAuthenticationMethod` – 准許在 EMR Serverless 受管 IAM Identity Center 應用程式上放置 authenticationMethod，以允許 emr-serverless 服務主體與 IAM Identity Center 應用程式互動。
+ `sso:PutApplicationAssignmentConfiguration` – 准許在 IAM Identity Center 應用程式上設定「User-assignment-not-required」設定。
+ `sso:PutApplicationGrant` – 准許在 IAM Identity Center 應用程式上套用 Token-exchange、introspectToken、refreshToken 和 revokeToken 授予。
+ `sso:PutApplicationAccessScope` – 准許將啟用信任身分傳播的下游範圍套用至 IAM Identity Center 應用程式。我們套用「redshift：connect」、「lakeformation：query」和「s3：read\$1write」範圍，以啟用這些服務的trusted-identity-propagation。

## 建立啟用信任身分傳播的 EMR Serverless 應用程式
<a name="security-iam-service-trusted-prop-create-emrs-app"></a>

您必須使用 指定 `—identity-center-configuration` 欄位`identityCenterInstanceArn`，才能在應用程式中啟用信任身分傳播。使用以下範例命令建立已啟用信任身分傳播的 EMR Serverless 應用程式。

**注意**  
您也必須將 指定`--interactive-configuration '{"livyEndpointEnabled":true}'`為僅針對 Apache Livy 端點啟用受信任身分傳播。

```
aws emr-serverless create-application \
  --release-label emr-7.8.0 \
  --type "SPARK" \
  --identity-center-configuration '{"identityCenterInstanceArn" : "arn:aws:sso:::instance/ssoins-123456789"}' \
  --interactive-configuration '{"livyEndpointEnabled":true}'
```
+ `identity-center-configuration` – （選用） 指定時啟用 Identity Center 信任的身分傳播。
+ `identityCenterInstanceArn`：(必要) Identity Center 執行個體 ARN。

如果您沒有必要的 Identity Center 許可 （先前提及），請先建立沒有信任身分傳播的 EMR Serverless 應用程式 （例如，不要指定`—identity-center-configuration`參數），然後要求 Identity Center Admin 透過叫用更新應用程式 API 來啟用信任身分傳播，請參閱下列範例：

```
aws emr-serverless update-application \
  --application-id applicationId \
  --identity-center-configuration '{"identityCenterInstanceArn" : "arn:aws:sso:::instance/ssoins-123456789"}'
```

EMR Serverless 會在您的帳戶中建立服務受管身分中心應用程式，服務會利用該應用程式來驗證身分，並將身分傳播到下游服務。EMR Serverless 建立的受管 Identity Center 應用程式會與您帳戶中所有啟用trusted-identity-propagation的 EMR Serverless 應用程式共用。

**注意**  
請勿手動修改受管 Identity Center 應用程式上的設定。任何變更都可能會影響您帳戶中所有啟用trusted-identity-propagation的 EMR Serverless 應用程式。

## 任務執行角色傳播身分的許可
<a name="security-iam-service-trusted-prop-job-execution-role-permissions"></a>

由於 EMR-Serverless 利用 Identity-enhanced job-execution-role 登入資料將身分傳播到下游 AWS 服務，因此 Job Execution Role 的 Trust-policy 必須具有額外的許可`sts:SetContext`，以使用身分增強任務執行角色登入資料，以允許受trusted-identity-propagation到下游服務，例如 S3 Access-grant、Lake Formation 或 Amazon Redshift。若要進一步了解如何建立角色，請參閱[建立任務執行期角色](getting-started.html#gs-runtime-role)。

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

****  

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

------

此外，JobExecutionRole 需要下游 AWS 服務的許可，其任務執行會使用使用者身分來擷取資料。請參閱以下連結來設定 S3 Access Grant、Lake Formation。
+ [搭配 EMR Serverless 使用 Lake Formation](lake-formation-section.html)
+ [搭配 EMR Serverless 使用 Amazon S3 Access Grants](access-grants.html)

# 互動式工作負載的受信任身分傳播
<a name="security-iam-service-trusted-prop-interactive-workloads"></a>

透過 Apache Livy 端點將身分傳播到互動式工作負載的步驟，取決於您的使用者是與 AWS 受管開發環境互動，例如， Amazon SageMaker AI 還是您自己的自我託管筆記本環境，做為面向用戶端的應用程式。

![\[EMR Serverless 流程圖。\]](http://docs.aws.amazon.com/zh_tw/emr/latest/EMR-Serverless-UserGuide/images/PEZ-SMAI.png)


## AWS 受管開發環境
<a name="security-iam-service-trusted-prop-aws-managed-development"></a>

下列 AWS 受管用戶端面向應用程式支援使用 EMR-Serverless Apache Livy 端點的受信任身分傳播：
+ [Amazon SageMaker AI](https://aws.amazon.com/sagemaker/ai/)

## 客戶管理的自我託管筆記本環境
<a name="security-iam-service-trusted-prop-self-hosted-notebook"></a>

若要為自訂開發應用程式的使用者啟用受信任身分傳播，請參閱 *AWS 安全部落格*中的[使用受信任身分傳播以程式設計方式存取 AWS 服務](https://aws.amazon.com/blogs/security/access-aws-services-programmatically-using-trusted-identity-propagation/)。

# 使用者背景工作階段
<a name="security-iam-service-trusted-prop-user-background"></a>

使用者背景工作階段可讓長時間執行的分析和機器學習流程繼續，即使使用者已從筆記本界面登出也一樣。此功能是透過 EMR Serverless 與 IAM Identity Center 受信任身分傳播功能的整合來實作。本節說明使用者背景工作階段的組態選項和行為。

**注意**  
使用者背景工作階段適用於透過筆記本界面啟動的 Spark 工作負載，例如 Amazon SageMaker Unified Studio。啟用或停用此功能只會影響新的 Livy 工作階段；現有的作用中 Livy 工作階段不會受到影響。

## 設定使用者背景工作階段
<a name="security-trusted-prop-user-background-config"></a>

使用者背景工作階段必須在兩個層級啟用，才能正常運作：

1. **IAM Identity Center 執行個體層級** – 通常由 IdC 管理員設定

1. **EMR Serverless 應用程式層級** – 由 EMR Serverless 應用程式管理員設定

### 為 EMR Serverless 應用程式啟用使用者背景工作階段
<a name="security-trusted-prop-user-background-enable"></a>

若要啟用 EMR Serverless 應用程式的使用者背景工作階段，您必須在建立或更新應用程式`identityCenterConfiguration`時，在 `true`中將 `userBackgroundSessionsEnabled` 參數設定為 。

**先決條件**
+ 用於建立/更新 EMR Serverless 應用程式的 IAM 角色必須具有 `sso:PutApplicationSessionConfiguration`許可。此許可允許 EMR Serverless 在 EMR Serverless 受管 IdC 應用程式層級啟用使用者背景工作階段。
+ 您的 EMR Serverless 應用程式必須使用發行標籤 7.8 或更新版本，且必須啟用受信任身分傳播。

**使用 啟用使用者背景工作階段 AWS CLI**

```
aws emr-serverless create-application \
    --name "my-analytics-app" \
    --type "SPARK" \
    --release-label "emr-7.8.0" \
    --identity-center-configuration '{"identityCenterInstanceArn": "arn:aws:sso:::instance/ssoins-1234567890abcdef", "userBackgroundSessionsEnabled": true}'
```

**若要更新現有的應用程式：**

```
aws emr-serverless update-application \
    --application-id applicationId \
    --identity-center-configuration '{"identityCenterInstanceArn": "arn:aws:sso:::instance/ssoins-1234567890abcdef", "userBackgroundSessionsEnabled": true}'
```

### 組態矩陣
<a name="security-trusted-prop-user-background-matrix"></a>

有效的使用者背景工作階段組態取決於 EMR Serverless 應用程式設定和 IAM Identity Center 執行個體層級設定：


**使用者背景工作階段組態矩陣**  

| IAM Identity Center userBackgroundSession 已啟用 | EMR Serverless userBackgroundSessionsEnabled | Behavior (行為) | 
| --- | --- | --- | 
| 是 | TRUE | 已啟用使用者背景工作階段 | 
| 是 | FALSE | 工作階段會隨著使用者登出而過期 | 
| 否 | TRUE | 應用程式建立/更新失敗並出現例外狀況 | 
| 否 | FALSE | 工作階段會隨著使用者登出而過期 | 

## 預設使用者背景工作階段持續時間
<a name="security-trusted-prop-user-background-duration"></a>

根據預設，所有使用者背景工作階段在 IAM Identity Center 中的持續時間限制為 7 天。管理員可以在 IAM Identity Center 主控台中修改此持續時間。此設定適用於 IAM Identity Center 執行個體層級，影響該執行個體內所有支援的 IAM Identity Center 應用程式。
+ 持續時間可以設定為 15 分鐘到 90 天之間的任何值。
+ 此設定是在 IAM Identity Center 主控台的設定 → **身分驗證** → **設定** （非互動式任務區段） 下**進行設定** 

**注意**  
EMR Serverless Livy 工作階段有單獨的持續時間上限 24 小時。工作階段會在達到 Livy 工作階段限制或使用者背景工作階段持續時間時終止，以先到者為準。

## 停用使用者背景工作階段的影響
<a name="security-trusted-prop-user-background-disabling"></a>

在 IAM Identity Center 中停用使用者背景工作階段時：

現有的 Livy 工作階段  
如果啟動時已啟用使用者背景工作階段，請繼續執行而不會中斷。這些工作階段將繼續使用其現有的背景工作階段字符，直到其自然終止或明確停止為止。

新的 Livy 工作階段  
將使用標準信任的身分傳播流程，並在使用者登出或其互動式工作階段過期時終止 （例如關閉 Amazon SageMaker Unified Studio JupyterLab 筆記本時）。

## 變更使用者背景工作階段持續時間
<a name="security-trusted-prop-user-background-changing-duration"></a>

在 IAM Identity Center 中修改使用者背景工作階段的持續時間設定時：

現有的 Livy 工作階段  
繼續執行與啟動時相同的背景工作階段持續時間。

新的 Livy 工作階段  
將為背景工作階段使用新的工作階段持續時間。

## 考量事項
<a name="security-trusted-prop-user-background-considerations"></a>

### 工作階段終止條件
<a name="security-trusted-prop-user-background-considerations-session"></a>

使用使用者背景工作階段時，Livy 工作階段將繼續執行，直到發生下列其中一種情況：
+ 使用者背景工作階段過期 （根據 IdC 組態，最多 90 天）
+ 管理員會手動撤銷使用者背景工作階段
+ Livy 工作階段達到閒置逾時 （預設值：上次執行陳述式後 1 小時）
+ Livy 工作階段達到其最長持續時間 (24 小時）
+ 使用者明確停止或重新啟動筆記本核心

### 資料持久性
<a name="prop-user-background-additional-data-persistence"></a>

使用使用者背景工作階段時：
+ 使用者一旦登出，就無法重新連線至其筆記本介面以檢視結果
+ 設定您的 Spark 陳述式，在執行完成之前將結果寫入持久性儲存體 （例如 Amazon S3)

### 成本影響
<a name="prop-user-background-additional-data-persistence-cost"></a>
+ 即使使用者結束其 Amazon SageMaker Unified Studio JupyterLab 工作階段，任務仍會繼續執行至完成，並在整個執行期間產生費用。
+ 監控您的作用中背景工作階段，以避免忘記或放棄的工作階段產生不必要的成本。

### 功能可用性
<a name="prop-user-background-additional-feature-availability"></a>

EMR Serverless 的使用者背景工作階段可用於：
+ 僅限 Spark 引擎 （不支援 Hive 引擎）
+ 僅限 Livy 互動式工作階段 （不支援批次任務和串流任務）
+ EMR Serverless 發行標籤 7.8 及更新版本

# EMR Serverless Trusted-Identity-Propagation 整合的考量事項
<a name="security-iam-service-trusted-prop-considerations-limitations"></a>

當您將 IAM Identity Center Trusted-Identity-Propagation 與 EMR Serverelss 應用程式搭配使用時，請考慮下列事項：
+ Amazon EMR 7.8.0 及更高版本支援透過 Identity Center 的受信任身分傳播，且僅適用於 Apache Spark。
+ 信任的身分傳播只能用於[透過 Apache Livy 端點搭配 EMR Serverless 的互動式工作負載](https://docs.aws.amazon.com/emr/latest/EMR-Serverless-UserGuide/interactive-workloads-livy-endpoints.html)。透過 EMR Studio 的互動式工作負載不支援受信任身分傳播
+ 批次任務和串流工作負載不支援受信任身分傳播
+ 使用使用受信任身分傳播的 AWS Lake Formation 的精細存取控制適用於[透過 Apache Livy 端點使用 EMR Serverless 的互動式工作負載](interactive-workloads-livy-endpoints.html)。
+ 下列 AWS 區域支援使用 Amazon EMR 的受信任身分傳播：
  + af-south-1 – 非洲 (開普敦)
  + ap-east-1 – 亞太區域 (香港)
  + ap-northeast-1 – 亞太區域 (東京)
  + ap-northeast-2 – 亞太區域 (首爾)
  + ap-northeast-3 – 亞太區域 (大阪)
  + ap-south-1 – 亞太區域 (孟買)
  + ap-southeast-1 – 亞太區域 (新加坡)
  + ap-southeast-2 – 亞太區域 (雪梨)
  + ap-southeast-3 – 亞太區域 (雅加達)
  + ca-central-1 – 加拿大 (中部)
  + ca-west-1 – 加拿大 （卡加利）
  + eu-central-1 – 歐洲 (法蘭克福)
  + eu-north-1 – 歐洲 (斯德哥爾摩)
  + eu-south-1 – 歐洲 (米蘭)
  + eu-south-2 – 歐洲 （西班牙）
  + eu-west-1 – 歐洲 (愛爾蘭)
  + eu-west-2 – 歐洲 (倫敦)
  + eu-west-3 – 歐洲 (巴黎)
  + me-central-1 – 中東 （阿拉伯聯合大公國）
  + me-south-1 – 中東 (巴林)
  + sa-east-1 – 南美洲 (聖保羅)
  + us-east-1 – 美國東部 (維吉尼亞北部)
  + us-east-2 – 美國東部 (俄亥俄州)
  + us-west-1 – 美國西部 (加利佛尼亞北部)
  + us-west-2 – 美國西部 (奧勒岡州)