Dowd and Associates

HowTo: Move an EC2 Instance Store AMI From One Region to Another

Moving an EC2 Instance Store AMI from one region to another is fairly straightforward and much easier than an EBS backed AMI.

To do this, we will need the following:

  • ec2-ami-tools
  • AWS Access Key ID
  • AWS Secret Key
  • An S3 Client
  • The kernel image to use in the new region

To install ec2-ami-tools, see our article: HowTo: Install AWS CLI – Amazon Elastic Compute Cloud (EC2) – AMI Tools. To find which kernel image to use in the new region, see our article HowTo: Amazon EC2 Kernel Images – PV Grub.

First we need to create a bucket in region we want to migrate to. In this article we’ll migrate to us-west-2. This can be done with s3curl like so

Console - user@hostname ~ $
1
2
3
4
s3curl.pl \
--id friendly_id \
--createBucket us-west-2 -- \
https://your_bucket_in_us-west-2.s3.amazonaws.com

Or this can be done in the S3 Management Console:

  • Click “Create Bucket” on the top of the left hand column
  • Choose your bucket name
  • Select “Oregon” from the Region dropdown

Now that we have bucket, we can migrate the image. We’ll set --owner-akid to your AWS Access Key ID and --owner-sak to your AWS Secret Key. The migration tool is picky about the destination bucket, you can only put it in the root level, however we can add a key prefix (move it to a subdirectory) after the migration.

Console - user@hostname ~ $
1
2
3
4
5
6
7
8
9
ec2-migrate-image \
--owner-akid C99F5C7EE00F1EXAMPLE \
--owner-sak a63xWEj9ZFbigxqA7wI3Nuwj3mte3RDBdEXAMPLE \
--bucket your_bucket/key_prefix \
--destination-bucket your_bucket_in_us-west-2 \
--manifest image.manifest.xml \
--location us-west-2 \
--kernel aki-c2e26ff2 \
--region us-west-2

Once the migration is done, we can move it to a new “directory”, the easiest way is to use the S3 Management Console to create a new directory and drag and drop the image files into said new directory.

Finally we register new image

Console - user@hostname ~ $
1
2
3
4
ec2-register \
--region us-west-2 \
--kernel aki-c2e26ff2 \
your_bucket_in_us-west-2/key_prefix/image.manifest.xml

And now we’re ready to run our AMI in the new region.

Comments