4

I am trying to migrate EC2 instances from one region to another. When an EC2 goes down in region A, how do I get this to start in region B? I am having a hard time trying to figure out what to do. I know how to copy EC2 instances within availability zones within one region but am seeing a lot of articles:

https://media.amazonwebservices.com/AWS_Migrate_Resources_To_New_Region.pdf http://www.serverwatch.com/server-tutorials/moving-ec2-instances-across-availability-zones-or-aws-regions.html

Stating that I need to use third party scripts in order to accomplish this. Does anyone have any experience moving EC2 instances from on region to another?

user3859018
  • 379
  • 1
  • 5
  • 14
  • 1
    You can copy an AMI of your instance to another region. This can be done easily through Web console. To do this using CLI, do the following: aws ec2 copy-image --source-image-id ami-5731123e --source-region us-east-1 --region ap-northeast-1 --name "My server" – Rakesh Bollampally May 12 '15 at 11:50

3 Answers3

5

There's no need to copy images from one region to another for purposes of redundancy. Each region has multiple availability zones, and those are meant to provide full fault tolerance within a given region. Each availability zone within a region is a physically distinct datacenter, and depending on the region there may be upwards of 3 to 5 availability zones. The chances of 3 or more availability zones in one region all suffering outages simultaneously is pretty small.

Depending on the complexity of your application you will likely get very good fault tolerance by simply deploying to multiple EC2 instances across multiple availability zones within the same region and putting an Elastic Load Balancer (ELB) in front of the application.

Another approach to fault tolerance is to make use of auto scaling, which not only ensures that a minimum number of EC2 instances is always running your application, but more instances can be launched automatically if the load on the application increases. Auto scaling can also be deployed across availability zones within a single reason to help ensure fault tolerance. At the simplest level, if you create an auto scaling group with both a minimum and maximum of 1 EC2 instance then AWS will ensure your application is already running, and if the EC2 instance fails for any reason then it will launch a new instance to replace it.

If you really do decide that you need to copy an instance from one region to another region then it will require multiple steps. You can't simply copy an instance from one region to another, so what you need to do is create an Amazon Machine Image (AMI) of the EC2 instance you're interested in, transfer the AMI to the new region, then launch new EC2 instances based on that AMI. It used to be necessary to use third party tools for this, but Amazon now offers the ability to do this directly. See this documentation on copying AMI's on how to do this.

Bruce P
  • 19,995
  • 8
  • 63
  • 73
  • 1
    Bruce - Thanks for the insight! Unfortunately for my use case, I must copy an instance from one region to another. With that being said, do you know of a way to automate the creation of this AMI within the EC2 Instance in Region B? – user3859018 May 12 '15 at 02:10
  • You'll need to [create an AMI](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/creating-an-ami-ebs.html) out of your EC2 instance in region A first. Then If you use [ec2-copy-image](http://docs.aws.amazon.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-CopyImage.html) it should copy the AMI from region A to B and provide you with the name of the new AMI in region B. – Bruce P May 12 '15 at 15:21
1

even i do understand the reasoning behind the answer of the person before me, still he/she did not answer your question.

So in order to move an AMI from one region to another simply click on the AMI in the console and Select "Copy AMI" it will ask you to what region you want to copy it to. Choose the destination and you are done.

Hope this helps. Peter V.

https://aws.amazon.com/about-aws/whats-new/2013/03/12/announcing-ami-copy-for-amazon-ec2/

Peter
  • 11
  • 1
1

Use the create-image AWS CLI command to create an AMI and then use the copy-image CLI command to copy the image to the new region.

The whole process is a little more complicated and involves up to 14 steps if you want to clone security groups, tag the instances and delete old instances.

I wrote a blog explaining all these steps in detail at https://medium.com/@gmusumeci/how-to-move-an-ec2-instance-to-another-aws-region-69ebaa68f12d

Guillermo