

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

# 使用 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 (憑證提供者類型)**：
  + **EMR 受管**

    選取此選項，讓 Amazon EMR 為您建立和儲存私有憑證。選取此選項時，Amazon EMR 會將所建立憑證授權單位的 PEM 編碼憑證上傳至您帳戶中 AWS Secrets Manager 的 ，供您在信任存放區中使用。您可以選擇性地設定用於此秘密的 KMS 金鑰和標籤。除了預設私有 DNS 萬用字元 (us-east-1 中的\*.ec2.internal 和所有其他區域中的 \*.{{region}}.compute.internal)，您也可以選擇性地指定所建立憑證的自訂有效期間，以及憑證 SAN 的自訂萬用字元尾碼。
  + **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 EMR 會為您建立和管理私有憑證，並使用可信任該區域的 EC2 私有 DNS 尾碼的萬用字元。建立之秘密的 ARN 會新增至顯示在 describe-security-configuration API 回應中的 CACertificateSecretARN 欄位。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
    "EncryptionConfiguration": {
        "EnableInTransitEncryption": true,
        "EnableAtRestEncryption": false,
        "InTransitEncryptionConfiguration": {
            "TLSCertificateConfiguration": {
                "CertificateProviderType": "EMR"
            }
        }
    }
}'
```

以下範例說明以下案例：
+ 使用 Amazon EMR 受管憑證啟用傳輸中資料加密，指定用於秘密建立的客戶 KMS 金鑰和標籤，並將區域的 EC2 公有 DNS 尾碼新增至已建立憑證的 SAN 清單。產生的 CA 憑證將在 30 天後過期，此時需要刪除並重新建立安全組態，才能繼續使用。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
    "EncryptionConfiguration": {
        "EnableInTransitEncryption": true,
        "EnableAtRestEncryption": false,
        "InTransitEncryptionConfiguration": {
            "TLSCertificateConfiguration": {
                "CertificateProviderType": "EMR",
                "AwsKmsKey": "arn:aws:kms:us-east-2:123456789012:key/12345678-1234-1234-1234-123456789012",
                "SecretTags": [{"Key": "cluster-type", "Value": "test"}],
                "WildcardDnsSuffix": "us-east-2.compute.amazonaws.com",
                "ValidityInDays": 30
            }
        }
    }
}'
```

以下範例說明以下案例：
+ 傳輸中資料加密啟用而靜態資料加密停用。
+ 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 EMR 受管憑證啟用傳輸中資料加密，指定用於秘密建立的客戶 KMS 金鑰和標籤，並新增至已建立憑證的 `*.mydomain.com` SAN 清單。
+ CSE-KMS 用於 Amazon S3 加密。
+ 本機磁碟加密使用其 ARN 參考的自訂金鑰提供者。

```
aws emr create-security-configuration --name "MySecConfig" --security-configuration '{
	"EncryptionConfiguration": {
		"EnableInTransitEncryption": true,
		"EnableAtRestEncryption": true,
		"InTransitEncryptionConfiguration": {
			"TLSCertificateConfiguration": {
				"CertificateProviderType": "EMR",
				"AwsKmsKey": "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012",
				"SecretTags": [{"Key": "cluster-type", "Value": "test"}],
				"WildcardDnsSuffix": "mydomain.com"
			}
		},
		"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 \| 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 \| 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"： "EMR" \| 「PEM」 \| "Custom" | Specifies whether to use EMR-created and managed certificates, 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}}" \| "{{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. | 
|  "AwsKmsKey" : "{{MyKeyARN}}" | Optional, only if EMR is specified for CertificateProviderType. A customer-managed key for uploading the created CA certificate to AWS Secrets Manager. {{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). | 
|  "SecretTags" ： 【{"Key"："mykey"，"Value"："myvalue"}】 | Optional, only if EMR is specified for CertificateProviderType. Tags to add to the created CA certificate in AWS Secrets Manager. To include this field the caller must have secretsmanager：TagResource permissions. | 
|  「ValidityInDays」：{{number}} | Optional, only if EMR is specified for CertificateProviderType. How many days the created certificates will be valid for, starting from the date of security configuration creation. If not specified, defaults to 20 years. | 
|  「WildcardDnsSuffix」：「mydomain.com」 | Optional, only if EMR is specified for CertificateProviderType. A domain to add with a wildcard prefix to the SAN list of the created certificates. Whether or not this is specified, the certificate will always include \*.ec2.internal in us-east-1 and \*.{{region}}.compute.internal in all other regions. | 
| **靜態加密參數** | 
| --- |
| "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" \| "SSE-KMS" \| "CSE-KMS" \| "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 \| 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" \| "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 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)。