Skip to main content

Command Palette

Search for a command to run...

AWS Zero to Hero Day 4 - part 2

Updated
2 min read
AWS Zero to Hero Day 4 - part 2
A

Final-year BSc IT student and DevOps Engineer with strong hands-on experience in AWS and cloud-native technologies. I focus on building, deploying, and automating reliable systems using modern DevOps practices.

I have practical experience working with Docker and Kubernetes for containerization and orchestration, Terraform and Ansible for infrastructure automation, and CI/CD pipelines using Jenkins, GitHub Actions, and AWS CodePipeline. I enjoy solving real-world problems related to deployment, scalability, and system reliability.

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.

Ans:

  1. Created AWS RDS with MySQL:

  2. 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
    
  3. Then, Created AWS AutoScaling Group with this template

  4. After that, I created an IAM role for EC2 service with RDS and CloudWatch full access, and attached it to my EC2 Instance

  5. Modified the RDS to connect with my Instance

  6. Connected to first instance, which is created from ASG

  7. and checked the databases content

  8. output images:

More from this blog

Amitabh Soni

90 posts

AWS Zero to Hero: Day 4 Insights