使用 CloudFormation 模板时如何为 AWS ECR 启用 KMS 加密

How to enable KMS encryption for AWS ECR when using CloudFormation templates

阅读有关 ECR CloudFormation 模板的 AWS 文档:

See here.

我无法找到如何指定您想要的静态加密。我知道默认情况下它使用 AES-256。但我希望能够指定 KMS。简单来说,我的模板如下所示:

Resources:
    logicalid:
        Type: 'AWS::ECR::Repository'
        Properties:
            RepositoryName : "repo-name"
            ImageScanningConfiguration:
                scanOnPush: "true"
            ImageTagMutability: "IMMUTABLE"
            EncryptionConfiguration:
                 encryptionType:"KMS"

但是 EncryptionConfiguration 不是一个有效的选项。我假设必须有一种方法,因为 SDK 允许您指定它:

See here

如有任何帮助,我们将不胜感激。谢谢!

尚不支持。 ECR 的 KMS 加密相当 new 而 CloudFormation 还没有这个选项。

唯一的方法是在 CloudFormation 中使用 custom resource 创建您的 ECR 存储库。

AWS 云构建现在支持指定 KMS 进行静态加密的选项。

https://github.com/aws-cloudformation/cloudformation-coverage-roadmap/issues/771