如何将自定义AMI从一个AWS账户复制到另一个账户。

huangapple go评论83阅读模式
英文:

how to copy custom AMI from one AWS account to another

问题

我已经使用Packer创建了自定义AMI,并保存在一个AWS账户中,现在我想将相同的AMI复制到另一个AWS账户中。

可以有人帮忙实现这个吗?

我已经尝试过以下命令:

aws ec2 copy-image --name "${AMI_Name}" --source-image-id "${AMI_ID}" --source-region "us-west-2" --copy-image-tags

但我感到困惑,因为我没有提供目标信息。

英文:

I have created custom AMI using packer and saved into one AWS account, now I want to copy same AMI into another AWS account.

Can anyone help here to achieve this?

I have tried

aws ec2 copy-image --name "${AMI_Name}" --source-image-id "${AMI_ID}" --source-region "us-west-2" --copy-image-tags 

but I am confused as I didn't provide the destination information

答案1

得分: 1

copy-image命令不会跨帐户复制AMI,它只会在同一帐户内不同区域之间复制。

要在不同帐户中使用AMI,您需要通过UI中的“编辑AMI权限”与另一个帐户共享它,并添加要与之共享AMI的帐户ID,或者使用以下命令:

aws ec2 modify-image-attribute
--image-id <<ami_id>>
--launch-permission "Add=[{UserId=<<remote_account_id>>}]"

英文:

copy-image command does not copy ami's across accounts, it does across regions within same account.

In order to use an ami in different account, you need to share it with another account by edit ami permissions from the UI and adding the account id that you want to share the ami with, or instead use the following command

> aws ec2 modify-image-attribute
--image-id <<ami_id>>
--launch-permission "Add=[{UserId=<<remote_account_id>>}]"

huangapple
  • 本文由 发表于 2023年6月22日 17:06:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76530253.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定