由于EC2 BillingProduct代码的神秘错误,无法复制图像

问题描述 投票:2回答:1

我正在尝试复制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)上的这个问题。

但是,此图像不是来自Marketplace,它不是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烘焙图像。

我没有想法。为什么会发生这种情况 - 我做错了什么,还是这种无证的行为?

amazon-web-services packer
1个回答
2
投票

事实证明,这个AMI的后代确实来自亚马逊商城。

烘焙管道的简化版本是:

账户A:

市场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

© www.soinside.com 2019 - 2024. All rights reserved.