EC2 Instance Migration to a different Region. How and why ?

EC2 Instance Migration to a different Region. How and why ?

AWS Cloud spans around 84 Availability Zones within 26 geographic regions around the world. With this Global Presence on a massive scale, AWS Customers use them to build their IT Infrastructure highly available and more robust.

global-infra_12.21.55a9a91c83fca005f2f773fbf445a4e14f4c6c66.png

In this Blog, We will see how we can migrate/copy AWS EC2 Server from one AWS Region to a different AWS Region Step by step.

Objective: Migrate EC2 from one AWS region to another AWS region

Prerequisites: AWS Account (Free Tier is Welcomed)
Putty

Why ? :
Let's say Company XYZ has started using AWS for one of their clients, and the primary condition is having a copy of the complete project setup available in multiple regions for a Disaster recovery Scenario.

How ? :
Follow the instructions given below to work on How to do it.

Follow Along :

  1. Create an Amazon EC2 Instance name "WebServer-Virginia" in Virginia region (us-east-1).
    (Select Amazon Linux 2 AMI and t2.micro instance type and all default settings in the Launch Instance Wizard).
    screely-1656778197855.png Note : Port 22 and Port 80 and 443 needs to open for Inbound Traffic in Security Group Settings. screely-1656779306911.png

  2. SSH into the EC2 Instance and Run below Commands to Install the Apache web server
    How to SSH EC2 using Putty from Windows Step-By-Step

    sudo yum update -y
    sudo yum install httpd -y 
    sudo service httpd start
    chkconfig httpd on
    sudo systemctl enable httpd
    sudo usermod -a -G apache ec2-user
    

    screely-1656779603518.png

    Boom !! Default Apache WebServer is ready. Wanna Test Default Test Page of Apache ?
    example: ec2-xx-xxx-x-xxx.compute-1.amazonaws.com

    Go to your EC2 Instance's Public IPv4 DNS copy URL and Open in a new Tab of a Browser. screely-1656780466157.png screely-1656779759337.png

    Now back to the main requirement, Next steps to Migrate this Default Web Server to a different AWS Region.

  3. Create a Snapshot of this VM EC2 Instance screely-1656780671606.png screely-1656781054641.png

  4. Create an Image (AMI-Amazon Machine Image) from a Snapshot screely-1656781137193.png screely-1656781541478.png

  5. Copy Image(AMI) to London Region (any other region in AWS)
    screely-1656781646435.png screely-1656781741058.png So far, Original Web Server EC2 is in AWS's Virginia Region (Us-east-1) and now It's AMI-Amazon Machine Image is Copied to London Region (Eu-west-2)

  6. Launch Instance in London Region from AMI
    screely-1656782906689.png Launch Instance from AMI screely-1656783002051.png Note: Launch Instance Wizard shows AMI is selected from London Region "ami-022aa40367eac6824" and New Name of the Instance will be "WebServer-London". Create New Keypair and Launch. Also Make Sure London Region's EC2 Instance's Security Group allow SSH and HTTP/S Traffic in inbound rules.
    screely-1656783397560.png screely-1656783953689.png The Launched Instance this time will be Launched in London Region (eu-West-2) Test your London Region Web Server for its Default Apache Test Page already setup by Going to London EC2 Instance's Public IPv4 DNS and copying the URL and Open in a new Tab of a Browser.
    Example : ec2-xx-xx-xx-xx.eu-west-2.compute.amazonaws.. screely-1656784302976.png screely-1656784369721.png

And this is how We successfully Migrated WebServer from Virginia Region to make WebServer in London Region.

Thank you for reading and following along with the Blog.

Happy Learning.

Like and Follow for more Azure and AWS Content.

Regards,
Jineshkumar Patel