How to programmatically migrate an EC2 EBS AMI to other regions

amazon ec2amazon-ebsamazon-web-services

Before EBS based AMIs were available, it was possible to use the command ec2-migrate-image in order to migrate AMIs to different regions.

Is there a simple way to do the same for EBS based AMIs? Either using the official amazon
EC2 API command line tools or using a library like boto?

Best Answer

Amazon has not provided a simple command line interface to copy EBS boot AMIs between regions like they did with S3 based AMIs.

In order to copy an EBS boot AMI, you need to start instances in both regions and copy the EBS snapshot from one region to the other using a temporary EBS volume attached to each instance.

I recommend using rsync with appropriate options to copy the file system, instead of copying the block device, as this is faster and should result in a smaller snapshot.

After the new snapshot has been created in the new region, you register it as an AMI, making sure you specify the correct architecture/AKI/ARI matching the ones in the source region.

I've written up the specific command lines necessary to accomplish all of this:

Copying EBS Boot AMIs Between EC2 Regions
http://alestic.com/2010/10/ec2-ami-copy

It is possible to put this together into an automated process, if that's what you need.