Saturday, October 4, 2014

How to move an EC2 Instance to another region

In this post I would describe the process of moving an EC2 instance to another region.

The background

I have a server in one of the EC2 regions that a bit pricey than the rest. It seems that moving it to another region would save me some bucks. Well, it turns out that I did a few blunders that maybe causes the savings to be negligible.

The initial plan

I read that snapshots could be copied to other regions. So the original plan is to create snapshots of existing volumes that support the instance (I have one instance with three EBS volumes), copy these to another region, and create a new instance in the new region.

The mistake

My mistake is that I assume creating a new instance is a simple matter of selecting the platform (i386 or x86_64) and the root EBS volume. Actually, it is not. First, we create an AMI (Amazon Machine Image) using an EBS snapshot, not EBS volume. Then we could launch a new instance based on the AMI. As shown below, when we are trying to create a new AMI from a snapshot we need to choose :

  • Architecture (i386 or x86_64)
  • Root device name - I knew this one
  • RAM disk ID 
  • Virtualization type - I chose paravirtual because that's what the original instance is
  • Kernel ID


The problem is, I cannot find the Kernel ID in the new region that matches the Kernel ID in the original region. Choosing default for the two parameters resulted in an instance that unable to boot successfully.


The real deal

So, it turns out that I chose the wrong path. From the Instance, I could Create Image, then after the image created, I could copy it to another region. 






After copying the image, we could launch a new instance based on the image.



Summary

Now we understood that the most efficient steps to copy an instance to another region is to create AMI from the instance, copy it to another region, and launch the AMI in the new region.



No comments: