

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

# 使用 AWS KMS 金鑰設定共用儲存加密
<a name="tutorials_04_encrypted_kms_fs-v3"></a>

了解如何設定客戶受管 AWS KMS 金鑰，以加密和保護針對 設定的叢集檔案儲存系統中的資料 AWS ParallelCluster。

使用 AWS ParallelCluster 命令列界面 (CLI) 或 API 時，您只需為建立或更新 AWS ParallelCluster 映像和叢集時建立 AWS 的資源付費。如需詳細資訊，請參閱[AWS 使用的 服務 AWS ParallelCluster](aws-services-v3.md)。

AWS ParallelCluster 支援下列共用儲存組態選項：
+ [`SharedStorage`](SharedStorage-v3.md) / [`EbsSettings`](SharedStorage-v3.md#SharedStorage-v3-EbsSettings) / [`KmsKeyId`](SharedStorage-v3.md#yaml-SharedStorage-EbsSettings-KmsKeyId)
+ [`SharedStorage`](SharedStorage-v3.md) / [`EfsSettings`](SharedStorage-v3.md#SharedStorage-v3-EfsSettings) / [`KmsKeyId`](SharedStorage-v3.md#yaml-SharedStorage-EfsSettings-KmsKeyId)
+ [`SharedStorage`](SharedStorage-v3.md) / [`FsxLustreSettings`](SharedStorage-v3.md#SharedStorage-v3-FsxLustreSettings) / [`KmsKeyId`](SharedStorage-v3.md#yaml-SharedStorage-FsxLustreSettings-KmsKeyId)

您可以使用這些選項，為 Amazon EBS、Amazon EFS 和 FSx for Lustre 共用儲存系統加密提供客戶受管 AWS KMS 金鑰。若要使用這些政策，您必須為下列項目建立和設定 IAM 政策：
+ [`HeadNode`](HeadNode-v3.md) / [`Iam`](HeadNode-v3.md#HeadNode-v3-Iam) / [`AdditionalIamPolicies`](HeadNode-v3.md#yaml-HeadNode-Iam-AdditionalIamPolicies) / [`Policy`](HeadNode-v3.md#yaml-HeadNode-Iam-AdditionalIamPolicies-Policy)
+ [`Scheduler`](Scheduling-v3.md#yaml-Scheduling-Scheduler) / [`SlurmQueues`](Scheduling-v3.md#Scheduling-v3-SlurmQueues) / [`Iam`](Scheduling-v3.md#Scheduling-v3-SlurmQueues-Iam) / [`AdditionalIamPolicies`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-Iam-AdditionalIamPolicies) / [`Policy`](Scheduling-v3.md#yaml-Scheduling-SlurmQueues-Iam-AdditionalIamPolicies-Policy) 

**先決條件**
+ AWS ParallelCluster [已安裝 ](install-v3-parallelcluster.md)。
+  AWS CLI [已安裝並設定 。](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
+ 您有 [Amazon EC2 金鑰對](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html)。
+ 您有一個 IAM 角色，具有執行 CLI [`pcluster`](pcluster-v3.md) 所需的[許可](iam-roles-in-parallelcluster-v3.md#iam-roles-in-parallelcluster-v3-example-user-policies)。

**Topics**
+ [建立政策](creating-the-role-v3.md)
+ [設定和建立叢集](creating-the-cluster-v3.md)

# 建立政策
<a name="creating-the-role-v3"></a>

在本教學課程中，您將建立使用 AWS KMS 金鑰設定共用儲存加密的政策。

**建立政策**

1. 前往 IAM 主控台：https：//[https://console.aws.amazon.com/iam/home](https://console.aws.amazon.com/iam/home)。

1. 選擇**政策**。

1. 選擇**建立政策**。

1. 選擇 **JSON** 索引標籤並貼上下列政策。請務必`123456789012`以您的 AWS 帳戶 ID 和金鑰 Amazon Resource Name (ARN) 取代所有出現的 ，並以您自己的 AWS 區域 取代。

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

****  

   ```
   {
       "Version":"2012-10-17",		 	 	 
       "Statement": [
           {
               "Effect": "Allow",
               "Action": [
                   "kms:DescribeKey",
                   "kms:ReEncrypt*",
                   "kms:CreateGrant",
                   "kms:Decrypt"
               ],
               "Resource": [
                   "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-abcd1234efgh5678"
               ]
           }
       ]
   }
   ```

------

1. 在本教學課程中，將政策命名為 `ParallelClusterKmsPolicy`，然後選擇**建立政策**。

1. 記下政策 ARN。您需要它來設定叢集。

# 設定和建立叢集
<a name="creating-the-cluster-v3"></a>

以下是範例叢集組態，其中包含具有加密功能的 Amazon Elastic Block Store 共用檔案系統。

```
Region: eu-west-1
Image:
  Os: alinux2
HeadNode:
  InstanceType: t2.micro
  Networking:
    SubnetId: subnet-abcdef01234567890
  Ssh:
    KeyName: my-ssh-key
  Iam:
    AdditionalIamPolicies:
      - Policy: arn:aws:iam::123456789012:policy/ParallelClusterKmsPolicy
Scheduling:
  Scheduler: slurm
  SlurmQueues:
    - Name: q1
      ComputeResources:
        - Name: t2micro
          InstanceType: t2.micro
          MinCount: 0
          MaxCount: 10
      Networking:
        SubnetIds:
          - subnet-abcdef01234567890
      Iam:
        AdditionalIamPolicies:
          - Policy: arn:aws:iam::123456789012:policy/ParallelClusterKmsPolicy
SharedStorage:
  - MountDir: /shared/ebs1
    Name: shared-ebs1
    StorageType: Ebs
    EbsSettings:
      Encrypted: True
      KmsKeyId: abcd1234-ef56-gh78-ij90-abcd1234efgh5678
```

將紅色文字中的項目取代為您自己的值。然後，建立使用 AWS KMS 金鑰在 Amazon EBS 中加密資料的叢集。

Amazon EFS 和 FSx for Lustre 檔案系統的組態類似。

Amazon EFS `SharedStorage`組態如下所示。

```
...
SharedStorage:
  - MountDir: /shared/efs1
    Name: shared-efs1
    StorageType: Efs
    EfsSettings:
      Encrypted: True
      KmsKeyId: abcd1234-ef56-gh78-ij90-abcd1234efgh5678
```

FSx for Lustre `SharedStorage`組態如下所示。

```
...
SharedStorage:
  - MountDir: /shared/fsx1
    Name: shared-fsx1
    StorageType: FsxLustre
    FsxLustreSettings:
      StorageCapacity: 1200
      DeploymentType: PERSISTENT_1
      PerUnitStorageThroughput: 200
      KmsKeyId: abcd1234-ef56-gh78-ij90-abcd1234efgh5678
```