AWS Zero to Hero Day 4 - part 2

Table of contents

Task 3: Deploy a scalable web application. The application consists of a MySQL database managed by Amazon RDS and a flask based web application that automatically scale based on demand using an Auto Scaling group and an Elastic Load Balancer.
- Deploy this: Two-tier application
Ans:
Created AWS RDS with MySQL:
Created EC2 template with following user data:
#!/bin/bash # Update system sudo apt update -y # Install Docker & MySQL client sudo apt install docker.io mysql-client -y # Add 'ubuntu' user to Docker group sudo usermod -aG docker ubuntu # Enable Docker service sudo systemctl enable docker sudo systemctl start docker # Wait until the RDS instance is ready to accept connections (optional but useful) until mysql -u admin -h database-1.cdsswsgcuo0c.us-east-1.rds.amazonaws.com -P 3306 -pdevops2004 -e "SELECT 1;" &>/dev/null; do echo "Waiting for MySQL..." sleep 5 done # Create the database if it doesn't exist mysql -u admin -h database-1.cdsswsgcuo0c.us-east-1.rds.amazonaws.com -P 3306 -pdevops2004 -e "CREATE DATABASE IF NOT EXISTS flaskdb;" # Pull your Flask app Docker image sudo docker pull amitabhdevops/aws-flask-app:latest # Run the Flask app sudo docker run -d \ --name flaskapp \ -e MYSQL_HOST=database-1.cdsswsgcuo0c.us-east-1.rds.amazonaws.com \ -e MYSQL_USER=admin \ -e MYSQL_PASSWORD=devops2004 \ -e MYSQL_DB=flaskdb \ -p 80:5000 \ amitabhdevops/aws-flask-app:latest
Then, Created AWS AutoScaling Group with this template
After that, I created an IAM role for EC2 service with RDS and CloudWatch full access, and attached it to my EC2 Instance
Modified the RDS to connect with my Instance
Connected to first instance, which is created from ASG
and checked the databases content
output images:
Subscribe to my newsletter
Read articles from Amitabh soni directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Amitabh soni
Amitabh soni
DevOps Enthusiast | Passionate Learner in Tech | BSc IT Student I’m a second-year BSc IT student with a deep love for technology and an ambitious goal: to become a DevOps expert. Currently diving into the world of automation, cloud services, and version control, I’m excited to learn and grow in this dynamic field. As I expand my knowledge, I’m eager to connect with like-minded professionals and explore opportunities to apply what I’m learning in real-world projects. Let’s connect and see how we can innovate together!