Migration of a Workload running in a Corporate Data Center to AWS using the Amazon EC2 and RDS service
Tags: aws, rds, ec2, mysql
Published: 2024-05-24 02:10:44


![](https://cdn-images-1.medium.com/max/3840/1*fdXk-sdxbc_48Hbf-fydgg.png)

In another project based on a real-world scenario, I acted as the Cloud Specialist responsible for migrating a workload running in a Corporate Data Center to AWS.
 The application and database were migrated to AWS using the Lift & Shift (rehost) model, moving both application and database data.

Migration steps:

 1. Planning: sizing, prerequisites, resource naming

 2. Implementation: resource provisioning, best practices

 3. Go-live: validation test — Dry-run, final migration — Cutover

 4. Post Go-live: ensuring the operation of the application and user access

![](https://cdn-images-1.medium.com/max/3840/1*IUtZKDJGH636FtnjEUaSlg.png)

 1. Planning

The client provided information and files for the application and the database to migrate from the on-premise environment to the AWS cloud.

Python Web — Wiki Server Application: Prerequisite python packages and libraries for the application to be run successfully on the AWS EC2 application server are determined.

MySQL 5.7 Python Web — Wiki DB Server: Size, host/server name, IP address, CPU, and necessary description are provided to migrate it to the Amazon RDB server.

![](https://cdn-images-1.medium.com/max/4724/1*30uTpS4HG0l9X1fpP5jPfw.png)

2. Implementation

* Create a VPC (Amazon Virtual Private Cloud): The purpose is to build a virtual and isolated network. The accessibility of the Amazon RDB and EC2 instance resources on the Internet will be controlled by the assignment of IP addresses. One public subset and two private subsets were added to VCP. The IPv4 CIDR block must not overlap with any existing CIDR block that’s associated with the VPC.

![](https://cdn-images-1.medium.com/max/2560/1*xt0IEANkdBP-bJ41h0xdaA.png)

![](https://cdn-images-1.medium.com/max/2556/1*0q04_IJyG2KCpiixCvowWA.png)

![](https://cdn-images-1.medium.com/max/2576/1*ltImZXnFiILlacdk6EGAfw.png)

* Create an Internet Gateway and attach it to a VPC: Necessary for the connection between EC2 and the Internet.

![Internet Gateway](https://cdn-images-1.medium.com/max/2676/1*ZfDWOQtmVzOljZGW7m8cfw.png)

![Attach Internet Gateway to VPC](https://cdn-images-1.medium.com/max/2792/1*0sqnEhlKfZ-f7ImqSP3a1A.png)

* Create a Route Table: There is already an attached route table to VPC when it is created but it is local and only routing internal traffics. We want to add new traffics to allow users coming from the Internet to access the EC2 application instance. The EC2 instance also can initiate internet connections from itself like connection to download packages etc.

![](https://cdn-images-1.medium.com/max/5004/1*kK5PGJoWeT8_etbI-5xwmw.png)

* Create an EC2 instance with a new Security Group and Key Pair (*.pem)*: EC2 instance(AMI: Ubuntu 18.04) within the previously launched VPC network was created.

* Key pair was created while creating the EC2 instance and downloaded to the desktop. It is necessary to connect remotely to the EC2 instance from the desktop via ssh.

* Security Group was created and configured to open a port so that we can access the services running on the virtual machine. A new security rule was added for the application to be accessed over the internet only port 8080.

![](https://cdn-images-1.medium.com/max/4240/1*IzrMUyczq4wHqt7njEy4Xw.png)

* Create MySQL RDS instance: It should be the same version from the on-promises environment or a newer version but we need to make sure this change will not affect anything else. Public access: No, never set it to “yes” if it is not really necessary.

![](https://cdn-images-1.medium.com/max/4148/1*_HYERT4qVSdRLDbPUMZ5vg.png)

* Pre-requisites steps: It should be connected to the EC2 instance using ssh and pair-key which was downloaded before in “.pem” format. It is important to prepare the EC2 instance to make the application work properly on it. Required python packages and libraries were installed as determined in the planning step.

* Set the permissions of your private key so that only you can read it. chmod 400 key-pair-name.pem

![](https://cdn-images-1.medium.com/max/4440/1*e5bmsP0yXeGR-RIHZ53qXg.png)

3. On-Live

This is broken into two steps, the validation (dry run) and the cutover.

Validation(dry-run):

The on-premises resources should be up and running at this stage. Once the validation is completed successfully, a downtime window can be scheduled when the business is not running and run the final migration switching from the on-premise environment to the cloud (cutover).

* 1) Database and 2) application deployment resources from the on-premises environment were exported and 3) put in an AWS S3 bucket. Then we can transfer files from the S3 bucket to related subnets in VCP. It is connected to the EC2 instance and opened remote connectivity from the local computer.

* 4) The application deployment files were imported to the EC2 instance.

$ ssh ubuntu@<PUBLIC_IP> -i <ssh_private_key>

![](https://cdn-images-1.medium.com/max/3228/1*5DQp728RQTZIlwkRhQaveA.png)

* 5) Remotely Connected to MySQL running on AWS RDS so that we can import the data coming from the on-premise DB. DB files were imported to the AWS RDB. 6) The connectivity between the EC2 instance and RDB was established in the application configuration file by pointing to the AWS RDB hostname.

![Create a Database named wikidb in MySQL running on AWS RDS](https://cdn-images-1.medium.com/max/5120/1*SAVLWNRHDRRIpOLqK4zoLg.png)

* A new user wiki in the wikidb was created so that application can go ahead and connect to the database, it will do connectivity from the application to the database.

![Create a new user in the wikidb](https://cdn-images-1.medium.com/max/2520/1*vW8Ha98ISi3MSYP2BZiaow.png)

* Unzip the app files, it is configuration files from the application that we want to point to MySQL DB running on AWS.

![Application configuration to point to MySQL DB running on AWS](https://cdn-images-1.medium.com/max/3228/1*5DQp728RQTZIlwkRhQaveA.png)

* Launch the application to validate the migration: Bring up the application to see if the application will be connected to the RDS.

<EC2_PUBLIC_IP>:8080

![](https://cdn-images-1.medium.com/max/5084/1*qX8TqeoT8FO5Wl7tba46jA.png)

* A new article was created to see if the application is able to not only read from MySQL database but also write on it.

![](https://cdn-images-1.medium.com/max/4688/1*VvJCv-qMXHGs82K9buIjEw.png)

Cutover: It is the next step of the On-Live process. So, in a production environment, we can schedule the downtime to bring the actual data from the on-premises environment, import the data, and make sure that the on-premises database and application are down. Once it is done we can switch from the on-premises environment to the AWS completely.

4. Post Go-Live:

Last step of migration. We should make sure there is no problem after go-live. Stability, ongoing support; access, performance, integration. Ongoing support can continue for 2 weeks, more or less depending on the complexity of the application.