Perform Lift and Shift migration with application migration service
Tags: aws, beginners, python, azure
Published: 2022-12-21 01:44:20

## Introduction
Advantage of AWS Application migration service
1. Primary migration service to do Lift and Shift Migration to AWS.
2. Allows physical, virtual and cloud server to migrate without any compatibility issue or performance disruption.
3. Simplifies and reduces cost of migrating servers and application to AWS.

The difference between the AWS Application migration service(MGN)and AWS server migration service(SMS) is that MGN uses continuous, block level replication and enables short cut over windows in minutes but in SMS uses incremental, snapshot based replication and the cutover windows are in hours, So according to the requirement one can choose.
In this blog I tried to migrate a linux server from Singapore region to Mumbai region.
<h2>Let’s start</h2>
Login to AWS account, choose Singapore region and launch a normal linux instance.
<img class="alignnone size-medium wp-image-847490" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration1-640x100.png" alt="" width="640" height="100" />
Now switch back to Mumbai region, a search for Application Migration Service.
I was directed to create a launch template, choose all the things I wanted like instance type, security group, subnet and all the necessary specification for the launch.
<img class="alignnone size-medium wp-image-847491" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration2-640x577.png" alt="" width="640" height="577" />
Clicked on add server and created a IAM user “mgn-agent-installer” and gave the ACCESS id and key.
<img class="alignnone size-medium wp-image-847492" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migartion3-640x268.png" alt="" width="640" height="268" />
<img class="alignnone size-medium wp-image-847502" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration14-640x126.png" alt="" width="640" height="126" />
Now logged into the linux instance (Singapore region) and executed these commands.
<code>
wget -O ./aws-replication-installer-init.py https://aws-application-migration-service-ap-south-1.s3.amazonaws.com/latest/linux/aws-replication-installer-init.py ## this will download the agent into the instance
</code>
<code>
sudo python3 aws-replication-installer-init.py --region ap-south-1 --aws-access-key-id “YOUR ACCESS KEY ID”—
aws-secret-access-key “YOUR ACCESS KEY” --no-prompt(this will install the agent and run it on the instance
</code>
<img class="alignnone size-medium wp-image-847495" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration4-640x254.png" alt="" width="640" height="254" />
As the agent is successfully installed and running, it will get reflected in the Application Migration service dashboard.
<img class="alignnone size-medium wp-image-847496" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration5-640x186.jpg" alt="" width="640" height="186" />
Wait for the replication to happen and it will take some time, it will be appear in the image shown below and the life cycle will be in <strong>not ready state.</strong>
<img class="alignnone size-medium wp-image-847497" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration6-640x270.png" alt="" width="640" height="270" />
When the lifecycle is <strong>ready for testing</strong> clicked on "test and cutover" and “launch test instance” now the instance will be launched as per the launch template created.
<img class="alignnone size-medium wp-image-847499" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migraton7-640x313.png" alt="" width="640" height="313" />
<img class="alignnone size-full wp-image-847500" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration10.png" alt="" width="522" height="780" />
Now test the application, as the instance in mumbai region got launched and the lifecycle will be in <strong>testing in progress</strong>.
<img class="alignnone size-medium wp-image-847518" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration9-640x141.png" alt="" width="640" height="141" />
<img class="alignnone size-medium wp-image-847501" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migraton8-640x157.png" alt="" width="640" height="157" />
As testing is completed, “mark for cutover” and lifecycle will come to <strong>ready for cutover</strong>
<img class="alignnone size-medium wp-image-847504" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration11-640x183.png" alt="" width="640" height="183" />
Clicked on launch cutover instance, (to cut the connection between with the agent) the lifecycle will be <strong>cutover in progress</strong>, clicked on Finalize cutover.
<img class="alignnone size-medium wp-image-847505" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration12-640x183.png" alt="" width="640" height="183" />
When the cutover is done then the lifecycle will be <strong>cutover complete</strong>.
<img class="alignnone size-medium wp-image-847506" src="https://d1tlzifd8jdoy4.cloudfront.net/wp-content/uploads/2022/03/migration13-640x183.png" alt="" width="640" height="183" />
<h2>The Error that i faced during the migration</h2>
1. Be every carefully with the region sometimes i got confused.
2. While creating template make sure the security groups, instance type, subnet and tags and properly given.
<h2>References</h2>
https://aws.amazon.com/blogs/publicsector/how-migrate-on-premises-workloads-aws-application-migration-service/