如何将加密的 AMI 从一个 aws 帐户复制到另一个帐户?

How do I copy an encrypted AMI from one aws account to another?

目前我正在使用 Packer 创建自定义 AMI,我想将它共享给我们的部署管道的多个 aws 帐户。

因为我有 "encrypt_boot": true,我得到这个错误: Errors validating build 'amazon-ebs'. 1 error(s) occurred: * Cannot share AMI encrypted with default KMS key

有人知道如何将加密的 AMI 共享到多个 AWS 账户吗?

你可以使用 AWS 请浏览博客 How to share encrypted AMIs across accounts to launch encrypted EC2 instances | AWS Security Blog.

正如其他人提到的,您必须使用 CMK 才能加密快照并与其他帐户共享。

您在 Packer 配置中指定密钥 kms_key_id and provide a list of target account IDs that are allowed to use the snapshots with snapshot_users. You can then use packer-post-processor-ami-copy 以将 AMI 复制到其他帐户。