

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 使用密 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 和 Lustre 共享存储系统 FSx 加密提供客户托管 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)。
+ 您拥有具有运行 [`pcluster`](pcluster-v3.md) CLI 所需的[权限](iam-roles-in-parallelcluster-v3.md#iam-roles-in-parallelcluster-v3-example-user-policies)的 IAM 角色。

**Topics**
+ [

# 创建策略
](creating-the-role-v3.md)
+ [

# 配置和创建集群
](creating-the-cluster-v3.md)

# 创建策略
<a name="creating-the-role-v3"></a>

在本教程中，您将创建一个使用密 AWS KMS 钥配置共享存储加密的策略。

**创建策略。**

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

1. 选择**策略**。

1. 选择**创建策略**。

1. 选择 **JSON** 选项卡，然后粘贴以下策略。请务必将所有出现的`123456789012`替换为您的 AWS 账户 ID 和密钥 Amazon 资源名称 (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 Lustre 文件系统的配置类似。

Amazon EFS `SharedStorage` 配置如下。

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

fo FSx r 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
```