Copy AMI cross-account

Posted on Dec 15, 2021
tl;dr: Copy an AMI from one account to another, or from one partition to another (i.e. commercial to GovCloud)

Copy AMI cross-account

This method works to copy any AMI from one account to another (without sharing or making it a public ami), or across different partitions, i.e. Commercial to GovCloud.

  1. In Commercial transfer AMI from ec2 to s3
aws ec2 create-store-image-task \
    --image-id ami-1234567890abcdef0 \
    --bucket myamibucket
  1. Wait for the transfer to complete, you can monitor itโ€™s progress:
aws ec2 describe-store-image-tasks
  1. Copy the AMI to an S3 bucket in Govcloud
aws s3 cp s3://myamibucket/ami-1234567890abcdef0.bin .
# switch partitions
aws s3 cp ami-1234567890abcdef0.bin s3://myamibucket-govcloud/
  1. In Govcloud move the AMI from S3 to EC2
aws ec2 create-restore-image-task \
    --object-key ami-1234567890abcdef0.bin \
    --bucket myamibucket-govcloud \
    --name "New AMI Name"
comments powered by Disqus