

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

# 使用安全組態來設定 Amazon EMR 叢集安全性
<a name="emr-security-configurations"></a>

您可以使用 Amazon EMR 安全組態，為叢集上的 EMRFS 設定資料加密、Kerberos 身分驗證和 Amazon S3 授權。首先，您需建立安全組態。然後，您可在建立叢集時使用及重複使用該安全組態。

您可以使用 AWS 管理主控台、 AWS Command Line Interface (AWS CLI) 或 AWS SDKs來建立安全組態。您也可以使用 AWS CloudFormation 範本來建立安全組態。如需詳細資訊，請參閱 [AWS CloudFormation 使用者指南](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/)和 [AWS::EMR::SecurityConfiguration](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-emr-securityconfiguration.html#cfn-emr-securityconfiguration-securityconfiguration) 的範本參考。

**Topics**
+ [使用 Amazon EMR 主控台或使用 建立安全組態 AWS CLI](emr-create-security-configuration.md)
+ [指定 Amazon EMR 叢集的安全組態](emr-specify-security-configuration.md)

# 使用 Amazon EMR 主控台或使用 建立安全組態 AWS CLI
<a name="emr-create-security-configuration"></a>

本主題涵蓋使用 Amazon EMR 主控台和 建立安全組態的一般程序 AWS CLI，後面接著包含 EMRFS 加密、身分驗證和 IAM 角色的參數參考。如需這些功能的詳細資訊，請參閱下列主題：
+ [使用 Amazon EMR 加密靜態和傳輸中的資料](emr-data-encryption.md)
+ [使用 Kerberos 透過 Amazon EMR 進行身分驗證](emr-kerberos.md)
+ [設定向 Amazon S3 請求使用 EMRFS 的 IAM 角色](emr-emrfs-iam-roles.md)

**使用主控台建立安全組態**

1. 在 https：//[https://console.aws.amazon.com/emr](https://console.aws.amazon.com/emr/) 開啟 Amazon EMR 主控台。

1. 在導覽窗格中，選擇 **Security Configurations (安全組態)**、**Create security configuration (建立安全組態)**。

1. 輸入安全組態的 **Name (名稱)**。

1. 選擇以下區段中所述的**加密**和**身分驗證**，然後選擇**建立**。

**使用 建立安全組態 AWS CLI**
+ 請使用 `create-security-configuration` 指令，如下列範例所示。
  + 針對 *SecConfigName*，指定安全組態的名稱。這是您在建立使用此安全組態的叢集時所指定的名稱。
  + 針對 `SecConfigDef`，指定內嵌的 JSON 結構或是本機 JSON 檔案的路徑，例如 `file://MySecConfig.json`。JSON 參數定義如以下區段所述的**加密**、**EMRFS 存取 Amazon S3 的 IAM 角色**和**身分驗證**選項。

  ```
  aws emr create-security-configuration --name "SecConfigName" --security-configuration SecConfigDef
  ```

## 設定資料加密
<a name="emr-security-configuration-encryption"></a>

在安全組態中設定加密前，請建立用於加密的金鑰和憑證。如需詳細資訊，請參閱[提供用於加密靜態資料的金鑰](emr-encryption-enable.md#emr-encryption-create-keys)及[使用 Amazon EMR 加密提供傳輸中資料的加密憑證](emr-encryption-enable.md#emr-encryption-certificates)。

您在建立安全組態時指定兩組加密選項：靜態資料加密和傳輸中資料加密。靜態資料加密選項包含「Amazon S3 與 EMRFS」和本機磁碟加密。傳輸中加密選項啟用支援 Transport Layer Security (TLS) 特定應用程式的開放原始碼功能。靜態和傳輸中的選項可同時啟用或分別啟用。如需詳細資訊，請參閱[使用 Amazon EMR 加密靜態和傳輸中的資料](emr-data-encryption.md)。

**注意**  
當您使用 時 AWS KMS， 會收取儲存和使用加密金鑰的費用。如需詳細資訊，請參閱[AWS KMS 定價](https://aws.amazon.com/kms/pricing/)。

### 使用主控台指定加密選項
<a name="emr-security-configuration-encryption-console"></a>

在 **Encryption (加密)** 中，根據下列的準則來選擇選項。
+ 選擇 **At rest encryption (靜態加密)** 下的選項來加密存放於檔案系統中的資料。

  您可以選擇加密 Amazon S3、本機磁碟或兩者的資料。
+ 在 **S3 資料加密**下，針對**加密模式**，選擇決定 Amazon EMR 如何使用 EMRFS 加密 Amazon S3 資料的值。

  您接下來要執行的動作取決於您選擇的加密模式：
  + **SSE-S3 (SSE-S3)**

    指定 [Amazon S3 受管加密金鑰的伺服器端加密](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingServerSideEncryption.html)。您不必再進行任何操作，因為 Amazon S3 會為您處理金鑰。
  + **SSE-KMS (SSE-KMS)** 或 **CSE-KMS (CSE-KMS)**

    指定[伺服器端加密與受管金鑰 AWS KMS(SSE-KMS)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingKMSEncryption.html) [或用戶端加密與受管金鑰 AWS KMS(CSE-KMS)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingClientSideEncryption.html)。針對 **AWS KMS key**，選取一個金鑰。金鑰必須與您的 EMR 叢集位於相同的區域中。如需金鑰需求，請參閱「[使用 AWS KMS keys 進行加密](emr-encryption-enable.md#emr-awskms-keys)」。
  + **CSE-Custom (自訂 CSE)**

    指定[使用自訂用戶端根金鑰 (CSE 自訂) 的用戶端加密](https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingClientSideEncryption.html#client-side-encryption-client-side-master-key-intro)。針對 **S3 物件**，輸入 Amazon S3 中的位置，或是您自訂金鑰提供者 JAR 檔案的 Amazon S3 ARN。接著，針對 **Key provider class (金鑰提供者類別)**，輸入在實作 EncryptionMaterialsProvider 界面的應用程式中，所宣告類別的完整類別名稱。
+ 在 **Local disk encryption (本機磁碟加密)** 下，選擇 **Key provider type (金鑰提供者類型)** 的值。
  + **AWS KMS key**

    選取此選項以指定 AWS KMS key。針對 **AWS KMS key**，選取一個金鑰。金鑰必須與您的 EMR 叢集位於相同的區域中。如需金鑰需求的詳細資訊，請參閱「[使用 AWS KMS keys 進行加密](emr-encryption-enable.md#emr-awskms-keys)」。

    **EBS 加密**

    當您指定 AWS KMS 做為金鑰提供者時，您可以啟用 EBS 加密來加密 EBS 根裝置和儲存磁碟區。若要啟用此類選項，您必須授予 Amazon EMR 服務角色 `EMR_DefaultRole` 使用您指定之 AWS KMS key 的許可。如需金鑰需求的詳細資訊，請參閱「[為 KMS 金鑰提供額外的許可來啟用 EBS 加密](emr-encryption-enable.md#emr-awskms-ebs-encryption)」。
  + **Custom**

    選擇此選項來指定自訂金鑰提供者。針對 **S3 物件**，輸入 Amazon S3 中的位置，或是您自訂金鑰提供者 JAR 檔案的 Amazon S3 ARN。針對 **Key provider class (金鑰提供者類別)**，輸入在實作 EncryptionMaterialsProvider 界面的應用程式中，所宣告類別的完整類別名稱。您在這裡提供的類別名稱必須不同於為自訂 CSE 提供的類別名稱。
+ 選擇 **In-transit encryption (傳輸中加密)**，來啟用傳輸中資料的開放原始碼 TLS 加密功能。根據下列的準則來選擇 **Certificate provider type (憑證提供者類型)**：
  + **PEM (PEM)**

    選擇此選項來使用您在 zip 檔案中提供的 PEM 檔案。在 zip 檔案中需要兩個成品：privateKey.pem 和 certificateChain.pem。第三個檔案的 trustedCertificates.pem 為選用。如需詳細資訊，請參閱 [使用 Amazon EMR 加密提供傳輸中資料的加密憑證](emr-encryption-enable.md#emr-encryption-certificates)。針對 **S3 物件**，指定 Amazon S3 中的位置，或指定 zip 檔案欄位的 Amazon S3 ARN。
  + **Custom**

    選取此選項來指定自訂憑證提供者，然後針對 **S3 物件**，輸入 Amazon S3 中的位置，或是您自訂憑證提供者 JAR 檔案的 Amazon S3 ARN。針對 **Key provider class (金鑰提供者類別)**，輸入在實作 TLSArtifactsProvider 界面的應用程式中，所宣告類別的完整類別名稱。

### 使用 指定加密選項 AWS CLI
<a name="emr-security-configuration-encryption-cli"></a>

下列的段落使用了案例範例，來說明不同組態和金鑰提供者的正確格式 **--security-configuration** JSON，以及 JSON 參數和適當值的參考。

#### 傳輸中資料加密選項範例
<a name="emr-encryption-intransit-cli"></a>

以下範例說明以下案例：
+ 傳輸中資料加密啟用而靜態資料加密停用。
+ Amazon S3 中包含憑證的 zip 檔案用作金鑰提供者 (如需憑證需求，請參閱 [使用 Amazon EMR 加密提供傳輸中資料的加密憑證](emr-encryption-enable.md#emr-encryption-certificates))。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
	"EncryptionConfiguration": {
		"EnableInTransitEncryption": true,
		"EnableAtRestEncryption": false,
		"InTransitEncryptionConfiguration": {
			"TLSCertificateConfiguration": {
				"CertificateProviderType": "PEM",
				"S3Object": "s3://MyConfigStore/artifacts/MyCerts.zip"
			}
		}
	}
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密啟用而靜態資料加密停用。
+ 使用自訂金鑰提供者 (如需憑證需求，請參閱「[使用 Amazon EMR 加密提供傳輸中資料的加密憑證](emr-encryption-enable.md#emr-encryption-certificates)」)。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
	"EncryptionConfiguration": {
		"EnableInTransitEncryption": true,
		"EnableAtRestEncryption": false,
		"InTransitEncryptionConfiguration": {
			"TLSCertificateConfiguration": {
				"CertificateProviderType": "Custom",
				"S3Object": "s3://MyConfig/artifacts/MyCerts.jar",
				"CertificateProviderClass": "com.mycompany.MyCertProvider"
			}
		}
 	}
}'
```

#### 靜態資料加密選項範例
<a name="emr-encryption-atrest-cli"></a>

以下範例說明以下案例：
+ 傳輸中資料加密停用而靜態資料加密啟用。
+ SSE-S3 用於 Amazon S3 加密。
+ 本機磁碟加密使用 AWS KMS 做為金鑰提供者。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
	"EncryptionConfiguration": {
		"EnableInTransitEncryption": false,
		"EnableAtRestEncryption": true,
		"AtRestEncryptionConfiguration": {
			"S3EncryptionConfiguration": {
				"EncryptionMode": "SSE-S3"
			},
			"LocalDiskEncryptionConfiguration": {
				"EncryptionKeyProviderType": "AwsKms",
				"AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
			}
		}
 	}
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密已啟用，並使用 ARN 參考 Amazon S3 中包含 PEM 憑證的 zip 檔案。
+ SSE-KMS 用於 Amazon S3 加密。
+ 本機磁碟加密使用 AWS KMS 做為金鑰提供者。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
	"EncryptionConfiguration": {
		"EnableInTransitEncryption": true,
		"EnableAtRestEncryption": true,
		"InTransitEncryptionConfiguration": {
			"TLSCertificateConfiguration": {
				"CertificateProviderType": "PEM",
				"S3Object": "arn:aws:s3:::MyConfigStore/artifacts/MyCerts.zip"
			}
		},
		"AtRestEncryptionConfiguration": {
			"S3EncryptionConfiguration": {
				"EncryptionMode": "SSE-KMS",
				"AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
			},
			"LocalDiskEncryptionConfiguration": {
				"EncryptionKeyProviderType": "AwsKms",
				"AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
			}
		}
	}
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密啟用，並參考 Amazon S3 中包含 PEM 憑證的 zip 檔案。
+ CSE-KMS 用於 Amazon S3 加密。
+ 本機磁碟加密使用其 ARN 參考的自訂金鑰提供者。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
	"EncryptionConfiguration": {
		"EnableInTransitEncryption": true,
		"EnableAtRestEncryption": true,
		"InTransitEncryptionConfiguration": {
			"TLSCertificateConfiguration": {
				"CertificateProviderType": "PEM",
				"S3Object": "s3://MyConfigStore/artifacts/MyCerts.zip"
			}
		},
		"AtRestEncryptionConfiguration": {
			"S3EncryptionConfiguration": {
				"EncryptionMode": "CSE-KMS",
				"AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
			},
			"LocalDiskEncryptionConfiguration": {
				"EncryptionKeyProviderType": "Custom",
				"S3Object": "arn:aws:s3:::artifacts/MyKeyProvider.jar",
				"EncryptionKeyProviderClass": "com.mycompany.MyKeyProvider"
			}
		}
	}
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密以自訂金鑰提供者啟用。
+ 自訂 CSE 用於 Amazon S3 資料。
+ 本機磁碟加密使用自訂金鑰提供者。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
	"EncryptionConfiguration": {
		"EnableInTransitEncryption": "true",
		"EnableAtRestEncryption": "true",
		"InTransitEncryptionConfiguration": {
			"TLSCertificateConfiguration": {
				"CertificateProviderType": "Custom",
				"S3Object": "s3://MyConfig/artifacts/MyCerts.jar", 
				"CertificateProviderClass": "com.mycompany.MyCertProvider"
			}
		},
		"AtRestEncryptionConfiguration": {
			"S3EncryptionConfiguration": {
				"EncryptionMode": "CSE-Custom",
				"S3Object": "s3://MyConfig/artifacts/MyCerts.jar", 
				"EncryptionKeyProviderClass": "com.mycompany.MyKeyProvider"
				},
			"LocalDiskEncryptionConfiguration": {
				"EncryptionKeyProviderType": "Custom",
				"S3Object": "s3://MyConfig/artifacts/MyCerts.jar",
				"EncryptionKeyProviderClass": "com.mycompany.MyKeyProvider"
			}
		}
	}
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密停用而靜態資料加密啟用。
+ 已使用 SSE-KMS 啟用 Amazon S3 加密。
+ 使用多個 AWS KMS 金鑰，每個 S3 儲存貯體一個，加密例外會套用至這些個別 S3 儲存貯體。
+ 停用本機磁碟加密。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
  	"EncryptionConfiguration": {
   		"AtRestEncryptionConfiguration": {
      	     	"S3EncryptionConfiguration": {
        			"EncryptionMode": "SSE-KMS",
        			"AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012",
        			"Overrides": [
         				 {
           				 "BucketName": "amzn-s3-demo-bucket1",
            				"EncryptionMode": "SSE-S3"
          				},
          				{
            				"BucketName": "amzn-s3-demo-bucket2",
           				 "EncryptionMode": "CSE-KMS",
            				"AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
         				 },
         				 {
           				 "BucketName": "amzn-s3-demo-bucket3",
          				  "EncryptionMode": "SSE-KMS",
           				 "AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
          				}
        					]
      							}
   						 	},
   		"EnableInTransitEncryption": false,
    		"EnableAtRestEncryption": true
  }
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密停用而靜態資料加密啟用。
+ 已使用 SSE-S3 啟用 Amazon S3 加密，且已停用本機磁碟加密。

```
aws emr create-security-configuration --name "MyS3EncryptionConfig" --security-configuration '{
    "EncryptionConfiguration": {
        "EnableInTransitEncryption": false,
        "EnableAtRestEncryption": true,
        "AtRestEncryptionConfiguration": {
            "S3EncryptionConfiguration": {
                "EncryptionMode": "SSE-S3"
            }
        }
     }
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密停用而靜態資料加密啟用。
+ 使用 AWS KMS 做為金鑰提供者啟用本機磁碟加密，並停用 Amazon S3 加密。

```
aws emr create-security-configuration --name "MyLocalDiskEncryptionConfig" --security-configuration '{
    "EncryptionConfiguration": {
        "EnableInTransitEncryption": false,
        "EnableAtRestEncryption": true,
        "AtRestEncryptionConfiguration": {
            "LocalDiskEncryptionConfiguration": {
                "EncryptionKeyProviderType": "AwsKms",
                "AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
            }
        }
     }
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密停用而靜態資料加密啟用。
+ 使用 AWS KMS 做為金鑰提供者啟用本機磁碟加密，並停用 Amazon S3 加密。
+ EBS 加密已啟用。

```
aws emr create-security-configuration --name "MyLocalDiskEncryptionConfig" --security-configuration '{
    "EncryptionConfiguration": {
        "EnableInTransitEncryption": false,
        "EnableAtRestEncryption": true,
        "AtRestEncryptionConfiguration": {
            "LocalDiskEncryptionConfiguration": {
                "EnableEbsEncryption": true,
                "EncryptionKeyProviderType": "AwsKms",
                "AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
            }
        }
     }
}'
```

以下範例說明以下案例：

SSE-EMR-WAL 用於 EMR WAL 加密

```
aws emr create-security-configuration --name "MySecConfig" \
    --security-configuration '{
        "EncryptionConfiguration": {
            "EMRWALEncryptionConfiguration":{ },
            "EnableInTransitEncryption":false, "EnableAtRestEncryption":false
        }
    }'
```

`EnableInTransitEncryption` 如果想要啟用相關加密， 和 `EnableAtRestEncryption` 仍然可能是 true。

以下範例說明以下案例：
+ SSE-KMS-WAL 用於 EMR WAL 加密
+ 伺服器端加密使用 AWS Key Management Service 做為金鑰提供者

```
aws emr create-security-configuration --name "MySecConfig" \
    --security-configuration '{
        "EncryptionConfiguration": {
            "EMRWALEncryptionConfiguration":{
                "AwsKmsKey":"arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012"
                },
            "EnableInTransitEncryption":false, "EnableAtRestEncryption":false
        }
    }'
```

`EnableInTransitEncryption` 如果想要啟用相關加密， 和 `EnableAtRestEncryption` 仍然可能是 true。

#### 適用於加密設定的 JSON 參考
<a name="emr-encryption-cli-parameters"></a>

下表列出加密設定的 JSON 參數，並提供每個參數可接受值的說明。


| 參數 | Description | 
| --- |--- |
| "EnableInTransitEncryption" : true \$1 false | Specify true to enable in-transit encryption and false to disable it. If omitted, false is assumed, and in-transit encryption is disabled. | 
| "EnableAtRestEncryption": true \$1 false | Specify true to enable at-rest encryption and false to disable it. If omitted, false is assumed and at-rest encryption is disabled. | 
| **傳輸中加密參數** | 
| --- |
| "InTransitEncryptionConfiguration" : | Specifies a collection of values used to configure in-transit encryption when EnableInTransitEncryption is true. | 
|  "CertificateProviderType": "PEM" \$1 "Custom" | Specifies whether to use PEM (PEM) certificates referenced with a zipped file, or a Custom certificate provider. If PEM (PEM) is specified, S3Object must be a reference to the location in Amazon S3 of a zip file containing the certificates. If Custom is specified, S3Object must be a reference to the location in Amazon S3 of a JAR file, followed by a CertificateProviderClass entry. | 
|  "S3Object" : "ZipLocation" \$1 "JarLocation" | Provides the location in Amazon S3 to a zip file when PEM (PEM) is specified, or to a JAR file when Custom is specified. The format can be a path (for example, s3://MyConfig/artifacts/CertFiles.zip) or an ARN (for example, arn:aws:s3:::Code/MyCertProvider.jar). If a zip file is specified, it must contain files named exactly privateKey.pem and certificateChain.pem. A file named trustedCertificates.pem is optional. | 
|  "CertificateProviderClass" : "MyClassID" | Required only if Custom is specified for CertificateProviderType. MyClassID specifies a full class name declared in the JAR file, which implements the TLSArtifactsProvider interface. For example, com.mycompany.MyCertProvider. | 
| **靜態加密參數** | 
| --- |
| "AtRestEncryptionConfiguration" :  | Specifies a collection of values for at-rest encryption when EnableAtRestEncryption is true, including Amazon S3 encryption and local disk encryption. | 
| Amazon S3 加密參數 | 
| "S3EncryptionConfiguration" : | Specifies a collection of values used for Amazon S3 encryption with the Amazon EMR File System (EMRFS). | 
| "EncryptionMode": "SSE-S3" \$1 "SSE-KMS" \$1 "CSE-KMS" \$1 "CSE-Custom" | Specifies the type of Amazon S3 encryption to use. If SSE-S3 is specified, no further Amazon S3 encryption values are required. If either SSE-KMS or CSE-KMS is specified, an AWS KMS key ARN must be specified as the AwsKmsKey value. If CSE-Custom (自訂 CSE) is specified, S3Object and EncryptionKeyProviderClass values must be specified. | 
| "AwsKmsKey" : "MyKeyARN" | Required only when either SSE-KMS or CSE-KMS is specified for EncryptionMode. MyKeyARN must be a fully specified ARN to a key (for example, arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012). | 
|  "S3Object" : "JarLocation" | Required only when CSE-Custom (自訂 CSE) is specified for CertificateProviderType. JarLocation provides the location in Amazon S3 to a JAR file. The format can be a path (for example, s3://MyConfig/artifacts/MyKeyProvider.jar) or an ARN (for example, arn:aws:s3:::Code/MyKeyProvider.jar). | 
| "EncryptionKeyProviderClass" : "MyS3KeyClassID" | Required only when CSE-Custom (自訂 CSE) is specified for EncryptionMode. MyS3KeyClassID specifies a full class name of a class declared in the application that implements the EncryptionMaterialsProvider interface; for example, com.mycompany.MyS3KeyProvider. | 
| 本機磁碟加密參數 | 
| "LocalDiskEncryptionConfiguration" | Specifies the key provider and corresponding values to be used for local disk encryption. | 
| "EnableEbsEncryption": true \$1 false | Specify true to enable EBS encryption. EBS encryption encrypts the EBS root device volume and attached storage volumes. To use EBS encryption, you must specify AwsKms as your EncryptionKeyProviderType. | 
| "EncryptionKeyProviderType": "AwsKms" \$1 "Custom" | Specifies the key provider. If AwsKms is specified, an KMS key ARN must be specified as the AwsKmsKey value. If Custom is specified, S3Object and EncryptionKeyProviderClass values must be specified. | 
| "AwsKmsKey : "MyKeyARN" | Required only when AwsKms is specified for Type. MyKeyARN must be a fully specified ARN to a key (for example, arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-456789012123). | 
| "S3Object" : "JarLocation" | Required only when CSE-Custom (自訂 CSE) is specified for CertificateProviderType. JarLocation provides the location in Amazon S3 to a JAR file. The format can be a path (for example, s3://MyConfig/artifacts/MyKeyProvider.jar) or an ARN (for example, arn:aws:s3:::Code/MyKeyProvider.jar). | 
|  `"EncryptionKeyProviderClass" : "MyLocalDiskKeyClassID"`  | Required only when Custom is specified for Type. MyLocalDiskKeyClassID specifies a full class name of a class declared in the application that implements the EncryptionMaterialsProvider interface; for example, com.mycompany.MyLocalDiskKeyProvider. | 
| **EMR WAL 加密參數** | 
| --- |
| 「EMRWALEncryptionConfiguration」  | Specifies the value for EMR WAL encryption. | 
| 「AwsKmsKey」  | Specifies the CMK Key Id Arn. | 

## 設定 Kerberos 身分驗證
<a name="emr-security-configuration-kerberos"></a>

Kerberos 設定的安全組態只能由以 Kerberos 屬性建立的叢集使用，否則會發生錯誤。如需詳細資訊，請參閱[使用 Kerberos 透過 Amazon EMR 進行身分驗證](emr-kerberos.md)。Kerberos 只能在 Amazon EMR 5.10.0 發行版本及更新版本中使用。

### 使用主控台指定 Kerberos 設定
<a name="emr-security-configuration-console-kerberos"></a>

根據下列的準則，在 **Kerberos authentication (Kerberos 身分驗證)** 中選擇選項。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/emr/latest/ManagementGuide/emr-create-security-configuration.html)

### 使用 指定 Kerberos 設定 AWS CLI
<a name="emr-kerberos-cli-parameters"></a>

以下參考資料表顯示安全組態中，Kerberos 設定的 JSON 參數。如需組態範例，請參閱[組態範例](emr-kerberos-config-examples.md)。

[\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/emr/latest/ManagementGuide/emr-create-security-configuration.html)

## 設定向 Amazon S3 請求使用 EMRFS 的 IAM 角色
<a name="emr-security-configuration-emrfs"></a>

EMRFS 的 IAM 角色可讓您提供 Amazon S3 中 EMRFS 資料的不同許可。存取請求包含您指定的識別符時，建立指定用於提供許可 IAM 角色的映射。識別符可以是 Hadoop 使用者或角色，或 Amazon S3 字首。

如需詳細資訊，請參閱[設定向 Amazon S3 請求使用 EMRFS 的 IAM 角色](emr-emrfs-iam-roles.md)。

### 使用 指定 EMRFS 的 IAM 角色 AWS CLI
<a name="w2aac30c17b9c15b7"></a>

以下是 JSON 程式碼片段範例，用於在安全組態內為 EMRFS 指定自訂 IAM 角色。它示範了三種不同標識符類型的角色映射，後接參數參考。

```
{
  "AuthorizationConfiguration": {
    "EmrFsConfiguration": {
      "RoleMappings": [{
        "Role": "arn:aws:iam::123456789101:role/allow_EMRFS_access_for_user1",
        "IdentifierType": "User",
        "Identifiers": [ "user1" ]
      },{
        "Role": "arn:aws:iam::123456789101:role/allow_EMRFS_access_to_demo_s3_buckets",
        "IdentifierType": "Prefix",
        "Identifiers": [ "s3://amzn-s3-demo-bucket1/","s3://amzn-s3-demo-bucket2/" ]
      },{
        "Role": "arn:aws:iam::123456789101:role/allow_EMRFS_access_for_AdminGroup",
        "IdentifierType": "Group",
        "Identifiers": [ "AdminGroup" ]
      }]
    }
  }
}
```


| 參數 | Description | 
| --- | --- | 
|  `"AuthorizationConfiguration":`  |  必要.  | 
|   `"EmrFsConfiguration":`  |  必要. 包含角色映射。  | 
|    `"RoleMappings":`  |  必要. 包含一或多個角色映射定義。角色映射以顯示的由上而下順序進行評估。如果對於 Amazon S3 中的資料的 EMRFS 呼叫，角色映射評估為 true，則不會評估進一步的角色映射，且 EMRFS 會為請求使用指定的 IAM 角色。角色映射包含下列必要參數： | 
|    `"Role":` | 以格式 `arn:aws:iam::account-id:role/role-name` 指定 IAM 角色的 ARN 識別符。如果向 Amazon S3 發出的 EMRFS 請求符合任何指定的 `Identifiers`，則這是 Amazon EMR 擔任的 IAM 角色。 | 
|    `"IdentifierType":` | 可為下列其中之一： [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/zh_tw/emr/latest/ManagementGuide/emr-create-security-configuration.html)  | 
|     `"Identifiers":`  |  指定適當識別符類型的一或多個識別符。以逗號分隔多個識別符，不含空格。  | 

## 設定對 Amazon EC2 執行個體的中繼資料服務請求
<a name="emr-security-configuration-imdsv2"></a>

*執行個體中繼資料* 是關於您執行個體的資料，您可以用來設定或管理執行中的執行個體。您可以使用以下其中一個方法，從執行中的執行個體存取執行個體中繼資料：
+ 執行個體中繼資料服務第 1 版 (IMDSv1) – 請求/回應方法
+ 執行個體中繼資料服務第 2 版 (IMDSv2) – 工作階段導向方法

雖然 Amazon EC2 同時支援 IMDSv1 和 IMDSv2，但 Amazon EMR 在 Amazon EMR 5.23.1、5.27.1、5.32 或更新版本以及 6.2 或更新版本中支援 IMDSv2。在這些版本中，Amazon EMR 元件使用 IMDSv2 進行所有 IMDS 呼叫。對於應用程式程式碼中的 IMDS 呼叫，您可以同時使用 IMDSv1 與 IMDSv2，或將 IMDS 設定為僅使用 IMDSv2 來增強安全性。當您指定必須使用該 IMDSv2 時，IMDSv1 則無法繼續運作。

如需詳細資訊，請參閱[《Amazon EC2 使用者指南》中的設定執行個體中繼資料服務](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html)。 *Amazon EC2 *

**注意**  
在較早 Amazon EMR 5.x 或 6.x 版本中，關閉 IMDSv1 會導致叢集啟動失敗，因為 Amazon EMR 元件使用 IMDSv1 進行所有 IMDS 呼叫。關閉 IMDSv1 時，請確保所有使用 IMDSv1 的自訂軟體都更新為 IMDSv2。

### 使用 指定執行個體中繼資料服務組態 AWS CLI
<a name="w2aac30c17b9c17c13"></a>

以下是用於在安全組態內指定 Amazon EC2 執行個體中繼資料服務 (IMDS) 的範例 JSON 程式碼片段。使用自訂安全組態是選用的。

```
{
  "InstanceMetadataServiceConfiguration" : {
      "MinimumInstanceMetadataServiceVersion": integer,
      "HttpPutResponseHopLimit": integer
   }
}
```


| 參數 | Description | 
| --- | --- | 
|  `"InstanceMetadataServiceConfiguration":`  |  如果您未在安全組態中指定 IMDS，並使用需要 IMDSv1 的 Amazon EMR 版本，Amazon EMR 預設會使用 IMDSv1 作為最低執行個體中繼資料服務版本。如果您想要使用自己的組態，則需要下列兩個參數。  | 
|   `"MinimumInstanceMetadataServiceVersion":`  |  必要. 可指定為 `1` 或 `2`。值 `1` 允許 IMDSv1 和 IMDSv2。值 `2` 僅允許 IMDSv2。  | 
|   `"HttpPutResponseHopLimit":`  |  必要. 在執行個體中繼資料請求上所需的 HTTP PUT 回應躍點限制。數字越大，可傳輸的執行個體中繼資料請求越多。預設：`1`。指定從 `1` 至 `64` 的整數。 | 

### 使用主控台指定執行個體中繼資料服務組態
<a name="emr-security-configuration-imdsv2-console"></a>

當您從 Amazon EMR 主控台啟動叢集時，您可以針對叢集設定 IMDS 的使用。

**若要使用主控台設定 IMDS 的使用，請執行以下操作：**

1. 在**安全組態**頁面上建立新的安全組態時，選取 **EC2 執行個體中繼資料服務**設定下的**設定 EC2 執行個體中繼資料服務**。此組態僅在 Amazon EMR 5.23.1、5.27.1、5.32 或更新版本以及 6.2 或更新版本中受支援。

1. 對於**最低執行個體中繼資料服務版本**選項，選取：
   + **關閉 IMDSv1 並僅允許 IMDSv2** – 如果您只想在此叢集上允許 IMDSv2。請參閱《Amazon EC[2 使用者指南》中的使用執行個體中繼資料服務第 2 版轉換至](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html#instance-metadata-transition-to-version-2) 。 *Amazon EC2 *
   + **在叢集上同時允許 IMDSv1 和 IMDSv2** – 如果您想要在此叢集上允許 IMDSv1 和工作階段導向的 IMDSv2。

1. 對於 IMDSv2，您也可以透過將 **HTTP put 回應跳轉限制**設定為介於 `1` 與 `64` 之間的整數，以為中繼資料字符設定允許的網路跳轉數量。

如需詳細資訊，請參閱[《Amazon EC2 使用者指南》中的設定執行個體中繼資料服務](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html)。 *Amazon EC2 *

請參閱《*Amazon EC2 使用者指南*》中的[設定執行個體詳細資訊](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/launching-instance.html#configure_instance_details_step)和[設定執行個體中繼資料服務](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html)。

# 指定 Amazon EMR 叢集的安全組態
<a name="emr-specify-security-configuration"></a>

指定安全組態來建立叢集時，您可以指定加密設定。您可以使用 AWS 管理主控台 或 AWS CLI。

------
#### [ Console ]

**使用主控台指定安全組態**

1. 登入 AWS 管理主控台，並在 https：//[https://console.aws.amazon.com/emr](https://console.aws.amazon.com/emr) 開啟 Amazon EMR 主控台。

1. 在左側導覽窗格中的 **EC2 上的 EMR** 下，選擇**叢集**，然後選擇**建立叢集**。

1. 在**安全組態和許可**下，尋找**安全組態**欄位。選取下拉式功能表，或選擇**瀏覽**以選取您先前建立的安全組態名稱。或者，選擇**建立安全組態**以建立可用於叢集的組態。

1. 選擇適用於您的叢集的任何其他選項。

1. 若要啟動您的叢集，請選擇**建立叢集**。

------
#### [ CLI ]

**使用 指定安全組態 AWS CLI**
+ 使用 `aws emr create-cluster` 選擇性以 `--security-configuration MySecConfig` 套用安全組態，其中 `MySecConfig` 是安全組態的名稱，如以下範例所示。指定的 `--release-label` 必須是 4.8.0 或更新版本，且 `--instance-type` 可以是任何可用。

  ```
  aws emr create-cluster --instance-type m5.xlarge --release-label emr-5.0.0 --security-configuration mySecConfig			
  ```

------