LAB 02

Application Migration with AWS MGN

Lift and shift an application server to AWS with continuous block-level replication and minimal-downtime cutover

⚙️ Lift & Shift 🔄 Block Replication ⏱ ~60 min 🏗️ Hands-On

Lab Architecture Overview

This lab migrates an entire application server from a simulated on-premises environment to AWS using Application Migration Service (MGN). The replication agent continuously copies disk blocks to a staging area, then MGN launches the final target instance on demand.

Source Environment — On-Premises Server

SOURCE VPC (ON-PREMISES) Source Application Server Amazon Linux 2 • Apache (httpd) + PHP 7.2 Web App (instanceData) • AWS Replication Agent BLOCK DATA

Target Environment — AWS Cloud

AWS CLOUD TARGET VPC Staging Area (Target-Pub-Staging) Replication Server Lightweight EC2 (auto-managed by MGN) • Receives block-level data INBOUND LAUNCH Public Subnet (Target-Pub-A) Target Application Server t3.small • TargetAppSG • EC2InstanceProfile • Auto-assign Public IP
💡 Architecture Note

The replication agent on the source server continuously streams disk blocks to the staging area over an encrypted connection. When you launch a test or cutover instance, MGN converts the replicated data into a bootable EBS volume and launches the target EC2 instance in your configured subnet with the specified security group and instance profile.

Migration Lifecycle — State Machine

AWS MGN tracks your server through a defined lifecycle. Each state represents a milestone in the migration journey — from initial replication through to final cutover. Watch the animation to see how a server progresses through the pipeline.

Not Ready
Agent installed, initial synchronization in progress
The replication agent begins copying all disk blocks from the source server. This full sync can take 10–15 minutes depending on disk size and network throughput.
🧪
Ready for Testing
Full replication complete — you can now launch a test instance
All source disk blocks have been replicated to the staging area. MGN continues capturing incremental changes while you prepare to validate the migration.
🚀
Test in Progress
Test instance launching and being validated
MGN converts replicated data into a bootable volume and launches a test EC2 instance using your launch template settings. Source replication continues uninterrupted.
Ready for Cutover
Test passed — ready for production cutover
You've validated the test instance works correctly. The test instance is terminated and MGN awaits your cutover command. Replication stays active to capture any new changes.
🔄
Cutover in Progress
Final instance launching — this is the real migration
MGN performs a final sync of any remaining changes, then launches the production cutover instance. This is the actual migrated server that will replace the source.
🏁
Cutover Complete
Migration finalized — staging resources cleaned up
The migration is done. Replication stops, staging servers are terminated, and the source server entry is archived. Your application now runs entirely on AWS.

Task Guide — Quick Reference

Expand each task for the goal, key configuration, and important notes. Use this as a condensed companion while working through the lab console steps.

01 Configure Source Application

Goal

Install Apache, PHP, and a sample web application on the source server to simulate an on-premises workload ready for migration.

Key Configuration

SettingValue
OSAmazon Linux 2
Web ServerApache (httpd)
RuntimePHP 7.2 (lamp-mariadb10.2-php7.2)
ApplicationinstanceData.zip (displays instance metadata)
Document Root/var/www/html
📝 Note

Connect via Session Manager — no SSH key required. The web app simply displays the EC2 instance ID and Availability Zone, making it easy to verify which server you're viewing after migration.

02 Verify Source Application

Goal

Confirm the web application is running and accessible via HTTP before starting the migration process.

Key Configuration

SettingValue
ProtocolHTTP (not HTTPS)
URLPublic DNS of Source Application Server
Expected OutputInstance ID + Availability Zone
⚠️ Important

Use HTTP, not HTTPS. The source server does not have an SSL certificate configured. Note down the instance ID — you'll compare it against the target after migration.

03 Set Up MGN Service

Goal

Initialize Application Migration Service, configure the replication template with the correct staging subnet, and obtain the agent installation commands.

Key Configuration

SettingValue
Staging area subnetTarget-Pub-Staging
Access KeyMigrationAccessKey (from lab resources)
Secret KeyMigrationSecret (from lab resources)
📝 Note

Copy both the download command and the install command to a text editor before navigating away. You'll need them in the next task when connecting to the source server.

04 Install Replication Agent

Goal

Download and run the AWS Replication Agent on the source server to begin continuous block-level replication to the staging area.

Key Configuration

StepCommand
Elevate privilegessudo su
Download agentsudo wget -O ./aws-replication-installer-init.py ...
Install agentsudo python3 aws-replication-installer-init.py ...
Success message"The AWS Replication Agent was successfully installed"
⚠️ Important

Run as root (sudo su) before executing the agent commands. After successful installation, type exit to drop root privileges. Replication begins automatically — no reboot required.

05 Configure Launch Settings

Goal

Customize the EC2 launch template that MGN uses when creating test and cutover instances — instance type, subnet, security group, and IAM profile.

Key Configuration

SettingValue
Right-sizingOff (disabled)
Instance typet3.small
SubnetTarget-Pub-A
Security groupTargetAppSG
Auto-assign public IPEnable
Name tagTarget Application Server
IAM instance profileEC2InstanceProfile
Default versionVersion 3
📝 Note

Disable right-sizing first (General launch settings), then modify the EC2 Launch Template. After creating the new template version, set it as the default (version 3) so MGN uses your configuration for all launches.

06 Launch Test Instance

Goal

Validate the migration by launching a non-disruptive test instance. This does not affect the source server or ongoing replication.

Key Configuration

StepDetail
Wait for statusReady for testing (10–15 min)
ActionTest and cutover → Launch test instances
MonitorLaunch history → Job ID → Status: Completed
After validationMark as "Ready for cutover"
📝 Note

The test instance launch takes 10–15 minutes. Once complete, verify the application works on the test instance, then mark the server as "Ready for cutover" to proceed to the final migration step.

07 Launch Cutover Instance

Goal

Launch the final production cutover instance — this is the actual migrated server that replaces the source.

Key Configuration

StepDetail
ActionTest and cutover → Launch cutover instances
MonitorLaunch history → Cutover Job ID
Duration~10–15 minutes
VerifyTarget Application Server in EC2 console
⚠️ Important

If you see "Failed to launch cutover instances" — the test instance is still being terminated. Wait 2–4 minutes and retry. The cutover instance uses the same launch template configuration you set up earlier.

08 Finalize Cutover

Goal

Stop replication, clean up staging resources, and mark the migration as complete. This is the final step.

Key Configuration

StepDetail
Verify target appHTTP access to Target Application Server public DNS
Expected outputNew instance ID + different AZ from source
Finalize actionTest and cutover → Finalize cutover
Final statusCutover complete
📝 Note

Finalizing the cutover terminates the replication server in the staging subnet and archives the source server entry. This action is irreversible — only finalize after confirming the target application works correctly.

Key Concepts

Core ideas behind application migration with AWS MGN. Understanding these concepts helps you make informed decisions during the migration process.

⚙️ Lift and Shift (Rehost)

Migrate an entire server as-is to AWS. The operating system, applications, configurations, and data are all replicated block-by-block — no application-level changes required.

🔄 Block-Level Replication

Copies raw disk blocks continuously rather than individual files. This captures everything including OS state, installed packages, and application binaries — providing a true 1:1 copy of the source.

📡 Replication Agent

A lightweight agent installed on the source server that streams disk changes to AWS. No reboot is needed during installation, and performance impact on the source workload is minimal.

🏗️ Staging Area

Temporary replication servers in the target VPC that receive and store replicated data. These are auto-managed by MGN and cleaned up when you finalize the cutover.

📋 Launch Template

Controls how the target EC2 instance is configured: instance type, subnet placement, security groups, IAM profile, and tags. You customize this before launching test or cutover instances.

🧪 Non-Disruptive Testing

Launch test instances without affecting the source server or ongoing replication. Validate that the migrated application works correctly before committing to the final cutover.

🏦 Banking Context — AnyCompany Bank

For AnyCompany Bank, MGN's non-disruptive testing is critical for migrating application servers that process financial transactions. Teams can validate that the migrated server handles payment workflows correctly before committing to cutover — ensuring zero transaction loss during the migration window. The block-level approach means no application code changes are needed, reducing risk for compliance-sensitive workloads.