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

AWS Cloud spans around 84 Availability Zones within [26 geographic regions](https://aws.amazon.com/about-aws/global-infrastructure/) 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1656786042130/QADCm9fqJ.png align="left")  

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](https://docs.aws.amazon.com/efs/latest/ug/gs-step-one-create-ec2-resources.html)).  
![screely-1656778197855.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656778206725/Kpz8tqjJk.png align="left")
Note : Port 22 and Port 80 and 443 needs to open for Inbound Traffic in Security Group Settings.
![screely-1656779306911.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656779351918/aBQbkkRt2.png align="left")  

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](https://asf.alaska.edu/how-to/data-recipes/connect-to-your-ec2-instance-using-putty-v1-1/)
```
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](https://cdn.hashnode.com/res/hashnode/image/upload/v1656779610556/Va094Oajb.png align="left")  

 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1656780481842/K6Nbg52tt.png align="left")
![screely-1656779759337.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656780042222/QxXfVhjpD.png align="left")

 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](https://cdn.hashnode.com/res/hashnode/image/upload/v1656780677702/VsF3tK1Q4.png align="left")
![screely-1656781054641.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656781061060/JfnzxNNr0.png align="left")  

4. Create an Image (AMI-Amazon Machine Image) from a Snapshot
![screely-1656781137193.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656781155457/jBQYf2Jsl.png align="left") ![screely-1656781541478.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656781548492/l7MKcN5lr.png align="left")

5. Copy Image(AMI) to London Region (any other region in AWS)  
![screely-1656781646435.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656781705665/yeGaqDxrM.png align="left")  ![screely-1656781741058.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656781748051/_VxaQv0jC.png align="left") 
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](https://cdn.hashnode.com/res/hashnode/image/upload/v1656782912852/kviiRooqW.png align="left")
Launch Instance from AMI
![screely-1656783002051.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656783009606/CUl_yG2GH.png align="left")
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](https://cdn.hashnode.com/res/hashnode/image/upload/v1656783403615/eO-zooXCQ.png align="left")
![screely-1656783953689.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656783970877/y_PKRFrTE.png align="left")
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 :  http://ec2-xx-xx-xx-xx.eu-west-2.compute.amazonaws.com/
![screely-1656784302976.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656784309545/DsLzLBu0H.png align="left")
![screely-1656784369721.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1656784380593/rfJsDecat.png align="left")  

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


