Migration of a Workload running in a Corporate Data Center to AWS using the Amazon EC2 and RDS service

Project description:

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

I followed some migration steps: Planning (sizing, prerequisites, resource naming), Execution (resource provisioning, best practices), Go-live (validation test — Dry-run, final migration — Cutover) and Post Go-live (ensure the operation of the application and user access).

Infrastructure

Implementation

VPC is a Virtual Private Cloud that isolate cloud

VPC Provisioning

  • Create a VPC:
  • VPC Name-production-1
  • CIDR Block: 10.0.0.0/16

Create Public and private subnet details:

-Public subnet

vpc-production-pub1
CIDR Block: 10.0.0.0/24

- Private subnet

vpc-production-1-pv-1
CIDR Block: 10.0.1.0/24

Creating an Internet Gateway, and Creating an Route

Attaching it to a VPC

VPC | Internet Gateway: igw-production | Action: Attach to VPC (vpc-production-1)

Creating Route table

VPC | Route Table | Routes | Edit routes | Add route: 0.0.0.0/0 — Target: Internet Gateway (igw-production)

EC2 Provisioning

- Create a new EC2 instance

  • Amazon Machine Image: Ubuntu 18.04
    - Instance type: t2.micro
    - Instance details:
    - Network: vpc-production-1
    - Subnet: vpc-production-pub1 (Public)
    - Assign public ip: Enable
    - Tags:
    - hostname: awsuse1app01
    - environment: bootcamp
    - Configure security group:
    - Port: 22 — Source: 0.0.0.0/0
    - Port: 8080 — Source: 0.0.0.0/0

RDS Provisioning

- Create a RDS instance

  • MySQL
    - MySQL 5.7.30
    - Templates: free-tier
    - Settings:
    - DB Instance: awsuse1db01
    - Master username: admin
    - Master password: admin123456
    - DB instance class: db.t2.micro
    - Storage: 20 GB
    - Connectivity:
    - VPC: vpc-production-1
    - Public access: No
    - Create new VPC security group
    - New VPC security group name: sec-group-db-01
    - Availability Zone: us-east-1a

steps to run in the EC2 instance awsuse1app01 (Application Server)

sudo apt-get update
sudo apt-get install python3-dev -y
sudo apt-get install libmysqlclient-dev -y
sudo apt-get install unzip -y
sudo apt-get install libpq-dev python-dev libxml2-dev libxslt1-dev libldap2-dev -y
sudo apt-get install libsasl2-dev libffi-dev -y

curl -O https://bootstrap.pypa.io/get-pip.py ; python3 get-pip.py — user

export PATH=$PATH:/home/ubuntu/.local/bin/pip3 install flask
pip3 install wtforms
pip3 install flask_mysqldb
pip3 install passlibsudo apt install awscli -y
sudo apt-get install mysql-client -y

Download the dump file and app file

wget https://tcb-bootcamps.s3.amazonaws.com/bootcamp-aws/en/wikiapp-en.zip
wget https://tcb-bootcamps.s3.amazonaws.com/bootcamp-aws/en/dump-en.sql

Connect on MySQL running on AWS RDS

mysql -h <RDS_ENDPOINT> -P 3306 -u admin -p

- Create the wiki DB and import data

create database wikidb;
use wikidb;
source dump-en.sql;

- Create the user wiki in the wikidb

CREATE USER wiki@’%’ IDENTIFIED BY ‘wiki123456’;

GRANT ALL PRIVILEGES ON wikidb.* TO wiki@’%’;

FLUSH PRIVILEGES;

- Unzip the app files

unzip wikiapp-en.zip
cd wikiapp

Edit the wiki.py file and change the MYSQL_HOST and point to the RDS endpoint.

vi wiki.py

  • Bring up the application

python3 wiki.py

<EC2_PUBLIC_IP>:8080

Login to the application (user:admin / password: admin)

- Create a new article

Thank you

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store