With Amazon Web Services (AWS), you can provision compute power, storage and other resources, gaining access to a suite of elastic IT infrastructure services as your business demands them. With minimal cost and effort, you can move your application to the AWS cloud and reduce capital expenses, minimize support and administrative costs, and retain the performance, security, and reliability requirements your business demands.
A simple Web Application using Flask and MySQL. This project has been based on CRUD application using Flask and MySQL and
this Hands on Microservices with Python,
this Application is docker based, the main objective of this project is elevate this Monolith to Microservices on AWS,
in order to achieve it we will install a Core Web Application from next examples with just a bit modification,
we have three options (we will use C Option):
-
A, Using local based install, please see Here
-
B, If you are familiar with docker you can use my docker approach, please see Here
-
C, Finally, Web Application with Microservices (this case is recommended it's has good fit about the initial use case), please see Here
The strategy is using "Forklift Migration Strategy", we will convert current approach from Monolithic to Microservices Application next steps below:
- Workload web application to AWS cloud.
- Its purpose is to decouple and modularise system services
- Leverage cloud
- Allow for horizontal scalability
- Separate the system concerns (Microservices)
- Isolated and decoupled deployments
- Allow for continuous delivery
- Allow for horizontal scalability
- Service can be scaled Independently
- Rehosting & Replatforming , lift-tinker-and-shift.
- Refactoring / Re-architecting
-
NOTE, SEE SOURCE DIAGRAM AT drawio.corp.amazon.com
Step 1. Creating and Setup EC2 Instance for initial environment.
- Go to Lunch instance wizard
- Chose Free tier and select, Amazon Linux 2 AMI (HVM), SSD Volume Type. . For instance type we will use t2.large it has well fit for Web Application Environment performance, please see more about Amazon EC2 Instance Types
- For ** Configure Instance Details** we will setup next Bootstrap script, for more information see Running commands on your Linux instance at launch
#!/bin/bash
yum update -y
yum install -y git
amazon-linux-extras install docker
service docker start
usermod -a -G docker ec2-user
curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
git clone https://github.com/radianv/master-builder-3.git
docker-compose -f /master-builder-3/workspace/dev/code-webapp-micro/frontend/docker-compose.deploy.yml up -d
chkconfig docker on
- Add Storage as is (just default).
- Add Tags, use next values:
key=Name
andValue=WebServer1
- Next Configure New Security Group, next values:
- Name: webMB3
- VPC: default
- Security group rules: Allow access to next ports:
80
,22
,3306
- Finally Review and Launch
Step 2. Create ELB and Target Groups.
- under construction
Step 3. Add WebServer to Target Group.
- under construction
Step 4. Migrate Data from Local MySQL to RDS using MDS Strategy 1
- Create the RDS instance either through the AWS console or using CloudFormation.
- Create the DMS replication instance and provision it in a subnet that can communicate with your non-RDS instance (source) and the RDS instance (target).
- Create a Source Endpoint and a Target Endpoint. The DMS instance will use this connection information to connect to the databases.
- Create the replication task.
- The migration process will begin.
- Verify data in the RDS instance.
- Connecting the WebApplication to a DB Instance Running the MySQL RDS.
Step 5. check the application is a Live on AWS: http://masterbuilder3.amazonaws.com/
Step 6. Using Cloud Formation to enable Environment, we will using Sceptre
- docker pull cloudreach/sceptre:2.1.4
- go to
cd cloud-formation
- you must configure you aws cli
- Run ¨docker run -it --entrypoint='' -v $(pwd):/project -v /home/ec2-user/.aws/:/root/.aws/:ro --name aws-sceptre cloudreach/sceptre:2.1.4 sh`
- or if the docker is already done you will use
docker start -ia aws-sceptre
cd my-sceptre-raw-project/
- EC2 Stack,
sceptre create dev/ec3-sample
please see Template into sceptre project Here. - RDS Mysql Stack,
sceptre create dev/ec3-sample
please see Template into sceptre project Here.
Step 1, Move the application to Microservices using ECS.
- under construction
Step 2, Containerize the Monolith
- under construction
Step 3, Deploy the Monolith
- under construction
Step 4. Break the Monolith
- under construction
step 5. Deploy Microservices
- under construction
Step 6. Using Cloud Formation enable Optimized Environment
cd my-sceptre-raw-project/
sceptre create dev/mb3-optimized.yaml