CloudFormation KMS 加密问题
CloudFormation KMS Encryption Questions
给定一个定义了以下内容的 CloudFormation 模板:
- KMS 密钥
- KMS 密钥别名
- 一个 S3 存储桶
如果出于某种原因我需要删除 CloudFormation 堆栈并重新部署,删除操作会保留创建的 KMS 密钥和别名。 (这很明智,我不想丢失所有加密的密钥)。
但这意味着当我重新部署堆栈时它失败了,因为同名的别名已经存在。
我可以通过 CLI 删除别名并重新部署,这将为新的 KMS 密钥创建别名。
CloudFormation 堆栈是否可以使用初始部署中的现有 KMS 密钥?
另外:我不是 100% 清楚 S3 存储桶中的加密数据在别名更改后会发生什么,AWS 是否知道自动查找以前加密过的 KMS 密钥或重新搜索-加密发生了吗?
我建议你有一个只创建 KMS 和 export its value on the outputs:
的堆栈
Resources:
KmsKey:
Type: AWS::KMS::Key
Properties:
...
Outputs:
S3KmsKeyId:
Description: The KMS Key used
Value: !Ref KmsKey
Export:
Name: S3KmsKeyId
然后你可以有第二个 Stack 只创建 S3 Bucket,你 reference the Exported Value:
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
...
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
KMSMasterKeyID: !ImportValue S3KmsKeyId
SSEAlgorithm: aws:kms
我能够使用单个堆栈创建加密的 S3 存储桶:
Resources:
S3EncryptionKey:
Type: AWS::KMS::Key
...
EncrypedS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
KMSMasterKeyID:
Ref: S3EncryptionKey
SSEAlgorithm: aws:kms
给定一个定义了以下内容的 CloudFormation 模板:
- KMS 密钥
- KMS 密钥别名
- 一个 S3 存储桶
如果出于某种原因我需要删除 CloudFormation 堆栈并重新部署,删除操作会保留创建的 KMS 密钥和别名。 (这很明智,我不想丢失所有加密的密钥)。
但这意味着当我重新部署堆栈时它失败了,因为同名的别名已经存在。
我可以通过 CLI 删除别名并重新部署,这将为新的 KMS 密钥创建别名。
CloudFormation 堆栈是否可以使用初始部署中的现有 KMS 密钥?
另外:我不是 100% 清楚 S3 存储桶中的加密数据在别名更改后会发生什么,AWS 是否知道自动查找以前加密过的 KMS 密钥或重新搜索-加密发生了吗?
我建议你有一个只创建 KMS 和 export its value on the outputs:
的堆栈Resources:
KmsKey:
Type: AWS::KMS::Key
Properties:
...
Outputs:
S3KmsKeyId:
Description: The KMS Key used
Value: !Ref KmsKey
Export:
Name: S3KmsKeyId
然后你可以有第二个 Stack 只创建 S3 Bucket,你 reference the Exported Value:
Resources:
S3Bucket:
Type: AWS::S3::Bucket
Properties:
...
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
KMSMasterKeyID: !ImportValue S3KmsKeyId
SSEAlgorithm: aws:kms
我能够使用单个堆栈创建加密的 S3 存储桶:
Resources:
S3EncryptionKey:
Type: AWS::KMS::Key
...
EncrypedS3Bucket:
Type: AWS::S3::Bucket
Properties:
BucketEncryption:
ServerSideEncryptionConfiguration:
- ServerSideEncryptionByDefault:
KMSMasterKeyID:
Ref: S3EncryptionKey
SSEAlgorithm: aws:kms