Compute Migration AWS to GCP with Migrate for Compute Engine (M4CE)
Cloud computing has revolutionized the way organizations manage their workloads, providing scalability, efficiency, and cost-effectiveness. In the dynamic landscape of cloud services, the need for migration between platforms arises, and one such common transition is from Amazon Web Services (AWS) to Google Cloud Platform (GCP). In this technical blog, we will delve into the intricacies of migrating compute instances (EC2) from AWS to GCP using the latest version of the Migrate for Compute Engine — Version 5.0.
In the fast-paced world of business, cloud migration is a strategic imperative. Migrating workloads seamlessly, especially when transitioning from AWS to GCP, requires careful planning and execution. The Migrate to Virtual Machine service, formerly known as Migrate for Compute Engine (M4CE), plays a pivotal role in achieving a smooth transition with minimal downtime and data integrity.
Migrate to Virtual Machines (M2VM) – Version 5.0:
Migrate to Virtual Machines is a powerful tool designed to migrate virtual machines (VMs) to Compute Engine from various source platforms, including VMware, Microsoft Azure, and Amazon EC2. The service employs live migration, cold migration, and offline migration techniques, ensuring flexibility in the migration process.
Key features of Migrate for Compute Engine include:
- Pre-migration and post-migration validation: Ensures compatibility and functionality of VMs before and after migration.
- Data replication: Replicates data to Compute Engine before migration, reducing downtime.
- Techniques: Live migration for minimal downtime, cold migration for idle VMs, and offline migration for inaccessible VMs.
Before initiating the migration process, certain prerequisites must be addressed:
- Create an AWS IAM Policy: Define permissions for EC2 instances and related resources.
- Create an IAM User: Enable programmatic access, attach the IAM policy, and store access key credentials.
- Optional: Tag EC2 Instances: Tag instances intended for migration to streamline the process.
Migration – Step-by-Step Execution:
Now, let’s walk through the step-by-step process of migrating virtual machines from AWS to GCP:
Step 1: Enable VM Migration API
In the GCP console, navigate to Compute Engine → Migrate to Virtual Machines. Enable the “VM Migration API” if not already enabled.
NOTE: You need to enable “VM Migration API”, in case you are using this service for the first time. If it is already enabled skip to the next step.
Step 2: Create an AWS Source in GCP-M4CE Service
After you enabled the VM Migration API in step 1, navigate to M4CE page
Navigation menu→ Compute Engine → Migrate to Virtual Machines.
In the dashboard, you can find the SOURCES tab. Click on it and click ADD SOURCE. Then Add AWS source.
Access the M4CE dashboard, go to the SOURCES tab, and click ADD SOURCE. Provide AWS source details, including name, AWS region, GCP region, access ID, and secret key.
Step 3: Add Source VM to the Migration List
After activation, select source VMs, click ADD MIGRATIONS, and choose VM Migration. This step prepares VMs for migration.
Select the checkboxes of the source VMs that you intend to migrate from AWS to the GCP environment.
Next, click on the “ADD MIGRATIONS” dropdown button. You will find two options: “VM Migration” and “Disk Migration.” Choose “VM Migration” since we are currently migrating the VM. If you wish to migrate disks, select the “Disk Migration” option from the dropdown.
Step 4: Add Target Projects
Just as we have added the sources from which the VMs are going to migrate, we will also describe the details about the targets where these VMs will be deployed after migration. By default, your current projects will be selected as the target project.
To add more target projects, navigate to the “TARGETS” tab. Then, click on the “+Add” button. This action will direct you to a slide page where you can select the target project by checking the corresponding checkbox. Once selected, click the “ADD” button.
Now, all the target projects will be listed under the “Target projects” tab.
Step 5: Add Target Details for Each VM
Since we added the target project in the previous step, we will now fine-tune the deployment of EC2-VMs to specific target projects.
To proceed, navigate to the “VM MIGRATION” tab, select the VM, and then click on the “EDIT TARGET DETAILS” button
a.) The “EDIT TARGET DETAILS” button will navigate to the target detail window. First we will add the General tab information, here we add the Instance name, target project and GCP-zone.
b.) The next tab “Machine Configuration” we will add information about the instance machine specification. Here, we setthe Machine type series, Machine type, Management and other metadata about the VM instance.
c.) Now, we are going to add the networking details, including the VPC, subnets, internal IP, network configuration, and network tags.
d.) Next, we can add the service account, disk type, and license details under the “Additional Configuration” tab.
e.) In the next two tabs, we can add details about the Sole Tenancy and Replication Policy.
Under the “Replication Policy” tab, we will set the Replication Idle Time between cycles in seconds. This idle time will trigger the replication of the source VMs after the defined time and synchronize the data.
In our case, we set it to 360, which means it will replicate the data every 1-hour when migration is in the IDLE state.
After configuring all the detailed settings, click on the “Save” button. Similarly, we can configure the target details for each migration VM.
Step 6: Start VMs Migration
To initiate the migration process, navigate to the “VM MIGRATIONS” tab, select all the VMs you want to migrate, click on the “MIGRATION” dropdown, and then click on “Start Replication.”
Once replication starts, we can track the replication status for each VM from the “Replication Status” section.
Step 7: Test-Clone Replicated VMs
Before performing the final cutover, the M4CE-v5 service offers a “Test-Clone” feature that allows you to validate the functionality of the data and applications running within the replicated VMs.
Once the replication of Migration VMs is completed and the Replication status shows as “Active (Idle),” the environment is ready for testing.
To continue, navigate to the “VM MIGRATION” tab, select the VMs in the “Active (Idle)” state, then click on the “CUT-OVER AND TEST-CLONE” dropdown and select the “Test-Clone” option.
CONFIRM. Then It will create a test-clone VM within 2–3 min.
In Compute Engine, test-cloning creates up-to-date replicas of the VMs as images without affecting the source VMs. These test clones appear as regular Compute Engine VMs and can be inspected just like any other instances.
In this case the test-clone VM will appear under the Compute Engine VM Instances, named “ashish-m4ce-test” as we described in step 5 in VM Targets General details.
The replicated image will continue to be updated while test clones are active. However, the test clones will retain the image state from when they were initially created, even as the ongoing replication process progresses. To test with newer images, you can initiate a new test clone. Once testing on the clones is complete, they can be safely deleted.
Step 8: Migration VM Cutover
After completing testing and validation, proceed with the cut-over process.
Keep in mind that during cut-over, source VMs will shut down, and cloud VMs will start up. A brief downtime may occur, so ensure necessary precautions are taken for critical applications.
To continue, navigate to the “VM MIGRATION” tab, select the VMs in the “Active (Idle)” state, then click on the “CUT-OVER AND TEST-CLONE” dropdown and select the “Cut-Over” option.
The cut-over process waits for ongoing replications to complete, shuts down source VMs, performs a final replication, and creates Compute Engine instances with the latest images. It will take 30–40 min to cutover. No further replications occur after this point (unless resumed manually).
1. To enable VMdeletion protection setup and keep boot disk, you have to edit the vm after migration.
2. After new VMs are up, validate. If all is well, finalize migration. If not, manually rollback by deleting instances in GCE and restarting VMs in the source environment.
Step 9: Finalize Migration
Finalizing a migration involves deleting all replication data and associated storage resources. If you don’t do this step, you will continue to get billed for the replication storage. It’s an important step to perform that is easily forgotten after migrations. It can be found under the “MIGRATION” drop-down.
Migrating compute instances from AWS to GCP demands meticulous planning and execution. The Migrate to Virtual Machines service, particularly Version 5.0, streamlines this process with enhanced features and simplified workflows. By following the step-by-step guide, organizations can seamlessly transition workloads, leveraging the benefits of Google Cloud Platform. This lift-and-shift approach minimizes disruptions and provides a foundation for future cloud-native solutions.