【问题标题】:Cannot copy an image due to mysterious error about EC2 BillingProduct code由于有关 EC2 BillingProduct 代码的神秘错误,无法复制图像
【发布时间】:2017-07-12 08:33:05
【问题描述】:

我正在尝试复制 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,并且其中没有任何 ProductCode:

$ 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】:

事实证明,这个 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 以供使用。

【讨论】:

  • 因此您可以共享图像、启动它并从正在运行的实例创建副本,而不是仅仅制作图像的副本。
猜你喜欢
  • 2018-01-11
  • 1970-01-01
  • 2019-07-05
  • 2019-05-16
  • 1970-01-01
  • 2012-04-14
  • 1970-01-01
  • 2016-06-17
  • 2021-05-22
相关资源
最近更新 更多