This project shows how I deployed a 2-tier web application on AWS using Terraform, Docker, and Bash scripting. The frontend is built using HTML + CSS, and the backend uses MySQL. The entire infrastructure and deployment process is automated.
The architecture has two tiers:
- Frontend (Public Subnet)
- Static website built with HTML & CSS
- Hosted on an EC2 instance in the public subnet
- Accessible through the Internet Gateway
- Backend (Private Subnet)
- MySQL database running inside a Docker container
- EC2 instance in the private subnet
- Only accessible from the frontend instance
Created a complete VPC using Terraform
- Public subnet for frontend, private subnet for backend
- Configured Internet Gateway + NAT Gateway
- Added route tables and associations
- Launched EC2 instance for frontend (HTML/CSS site)
- Launched EC2 instance for backend (MySQL container)
- Implemented bastion host for SSH access
- Wrote Bash scripts for:
- Starting frontend
- Setting up MySQL
- Automating service start
- Stored Terraform state remotely for reproducible deployments
- AWS EC2, VPC, Subnets
- Terraform (IaC) = Docker
- MySQL
- HTML + CSS (Frontend UI)
- Bash Scripting
- Security Groups
- NAT Gateway, Internet Gateway
2Tier-DevOps-Project/
|-- app/
| |-- backend/
| │-- index.html
| │-- style.css
| |-- Dockerfile
| |-- script.js
| |-- frontend/
| |-- Dockerfile
| |-- server.js
│-- terraform/
│ │-- main.tf
│ │-- vpc.tf
│ │-- frontend.sh
│ │-- backend.sh
│ │-- variables.tf
│ │-- outputs.tf
- Initialize Terraform
- terraform init
- Validate
- terraform validate
- Preview deployment
- terraform plan
- Apply
- terraform apply
- VPC
- Subnets
- EC2 instances
- NAT + IGW
- Security groups
- Then your Bash scripts will:
- Start frontend (HTML/CSS)
- Deploy MySQL container
- Initialize database
- How to deploy a 2-tier architecture on AWS
- Using Terraform to automate cloud infrastructure
- Working with public & private subnets
- Deploying a static website on EC2
- Running MySQL inside Docker
- Writing automation scripts using Bash
- Using security groups to control access