我正在尝试复制EC2图像以加密它。
我发出的命令行是:
$ aws ec2 copy-image --name encrypted-kafka-201707121432 \
--source-region ap-southeast-2 --encrypted --source-image-id ami-2a617249 \
--region ap-southeast-2
这会导致发出以下错误:
An error occurred (InvalidRequest) when calling the CopyImage operation:
Images with EC2 BillingProduct codes cannot be copied to another AWS account.
我环顾四周,我了解复制Windows AMI时通常会看到此错误(例如here),这与SO上的此问题类似(here)。
但是,此图片并非来自市场,并且它不是Windows AMI,并且其中没有任何ProductCodes:
$ aws ec2 describe-images --image-ids ami-2a617249 --region ap-southeast-2 \
--query '.Images[].ProductCodes'
[]
将此与另一个相提并论:
$ aws ec2 describe-images --image-ids ami-00280263 --region ap-southeast-2 \
--query '.Images[].ProductCodes'
[
{
"ProductCodeType": "marketplace",
"ProductCodeId": "dsli9z1o9amfv5g2hsmdj1pph"
}
]
使用Packer烘焙图像。
我没有想法。为什么会发生这种情况 - 我做错了什么,或者这是没有记录的行为?
答案 0 :(得分:2)
事实证明,这个AMI的后代确实来自亚马逊商城。
烘焙管道的简化版本是:
帐户A:
Marketplace AMI(ami-xxxxxxxx) - >打包器构建(ami-yyyyyyyy) - >分享到账户B
帐户B:
然后我发出了:aws ec2 copy-image --encrypted --source-image ami-yyyyyyyy
并收到:
An error occurred (InvalidRequest) when calling the CopyImage operation:
Images with EC2 BillingProduct codes cannot be copied to another AWS account.
从帐户B我可以查看所有者,即与我分享的帐户:
$ aws ec2 describe-images --image-id ami-yyyyyyyy --region ap-southeast-2 \
> --query 'Images[0].OwnerId'
这会返回帐户A的16位帐户ID。
此时,了解使用Packer烘焙AMI会导致产品代码显然丢失是有帮助的。但是,这些产品代码仍然存在,亚马逊支持可以看到它们。它需要致电亚马逊支持部门确认此部分。
为了解决这个问题,我现在在Python或Bash(AWS CLI)中维护一个可以使用的脚本encrypt_ami。