EBS backed AMI become instance-store AMI when migrate across region

I'm a bit confused here. I've been trying this for days but couldn't get it to work. Hopefully someone could shed some light here.

I have 1 instance (Amazon AMI x86_64 AMI, EBS backed) running in us-east-1 region, and I wanted to migrate to ap-southeast-1 region (using S3 bucket).

Here are the steps I've taken:

 1. ec2-bundle-vol \
    -k pk-xxx.pem \
    -u xxx \
    -c cert-xxx.pem

 2. ec2-migrate-manifest \
    -m /tmp/image.manifest.xml \
    -c cert-xxx.pem \
    -k pk-xxx.pem \
    -a xxx \
    -s xxx \
    --region ap-southeast-1

 3. ec2-upload-bundle \
    -b my-sg-bucket \
    -m /tmp/image.manifest.xml \
    -a xxx \
    -s xxx \
    --location ap-southeast-1

 4. ec2-register \
    -K pk-xxx.pem \
    -C cert-xxx.pem \
    --region ap-southeast-1 \
    my-sg-bucket/image.manifest.xml \
    --name my-ami

Everything was working fine. I'm able to see the newly created AMI in AP region. But when I tried to create an instance with the AMI, I can't choose 't1.micro' as the instance type. I soon find out that the AMI is an instance-store AMI (strange it is EBS backed in the first place).

This lead me thinking what I've done wrong here to migrate an EBS backed instance to different region without changing it to instance-store AMI?

Thanks.


The problem you see is because the command 'ec2-bundle-vol' is for creating S3-backed AMIs. You have therefore, taken your EBS backed AMI - created, uploaded, and registered its contents as an S3 backed AMI, and then launched that S3 backed AMI in the new region.

Unfortunately, there is no built in way to migrate an AMI with an EBS root between regions. You need to go about it the long way.

  • Firstly, create a snapshot of the root volume you want to migrate
  • Then, start up an instance in the source and destination regions.
    • if you don't want to have different keys for the instances (since they are in different regions), you should import your own keypair first.
  • Create an EBS volume from your snapshot, and attach it to the instance in your source region.
  • Create a new (empty) EBS volume, in the destination region, and attach to the instance you started there.
  • Format the EBS volume in the destination region with the desired file system
  • Copy the data between the EBS volumes
    • rsync over SSH is likely the way to go
  • Create a snapshot of the new (destination) EBS volume
  • Register an AMI based on that snapshot
  • Terminate the instances you started, when you are done with them

You will incur costs for the instances, the data transfer, and the EBS I/O.


There is actually another option that might be better suited to your needs.

S3-backed AMIs can be downloaded and unbundled, yielding an image of the original disk - you can then write that image to your EBS volume, and should be good to go.

Essentially, you would perform the same first steps as you already have:

  • ec2-bundle-vol ...
  • ec2-migrate-manifest ...
  • ec2-upload-bundle ...

Then, in the destination region:

  • Start a new instance, and attach a sufficiently sized EBS volume
    • You will also need enough free space on the instance to store the image temporarily (the ephemeral storage on a small instance should be ample).

  • Download your bundled volume to the instance:
    ec2-download-bundle -b BUCKET_NAME -m MANIFEST.xml -d TARGET_DIRECTORY
    • You also need to either pass your ACCESS_KEY, SECRET_ACCESS_KEY, and PRIVATE_KEY, or have then set as environment variables.

  • Unbundle the volume:
    ec2-unbundle  -m /local/path/to/manifest.xml -s SOURCE_DIRECTORY -d DESTINATION_DIRECTORY
  • Copy to EBS Volume:
    dd if=/path/to/image of=/dev/NAME

Migrating instances across regions is indeed not as straight forward as one would like to think, albeit a solved problem:

  • The commonly used approach is explained in Eric Hammonds's elaborate article Copying EBS Boot AMIs Between EC2 Regions.
  • The same approach is illustrated in Rob Linton's more visual presentation Migrating EBS AMI's betweeen AWS Regions.
  • Finally, Ahmed Abdalla had started to implement an EC2 tool to migrate EBS backed AMIs across regions based on boto in February 2011, which looks quite promising, but has unfortunately stopped short of completing all the required usual steps outlined in the respective Blueprint, see EC2 Migrate EBS AMI tool, call for volunteers for details on the state of affairs:
    • Project is now able to launch two utility instances in the two specified regions, and mount the source volume in the source instance
    • What remains is attaching a destination volume, and sync'ing over contents.