AWS infrastructure demonstrating Amazon S3 Files, Regional NAT Gateway, Terraform, Docker, Amazon ECR, Application Load Balancer and Auto Scaling Group.
- Project Overview
- Architecture
- Features
- Tech Stack
- Project Structure
- Infrastructure Components
- Deployment Workflow
- Deployment Steps
- Docker Workflow
- Security
- Validation
- Troubleshooting
- Future Improvements
- Cleanup
This project demonstrates how we can use AWS S3 bucket as shared storage for an application on AWS using Infrastructure as Code.
The application serves images stored in Amazon S3 Files. Every EC2 instance launched by the Auto Scaling Group mounts the same shared storage, ensuring consistent content across all instances behind the Application Load Balancer.
Infrastructure is fully provisioned using Terraform.
Request Flow:
Users → Internet → Application Load Balancer → Target Group → Auto Scaling Group → EC2 → Docker → Amazon S3 Files → Amazon S3
- Terraform Infrastructure as Code
- Highly Available Architecture
- Application Load Balancer
- Auto Scaling Group
- EC2 in Private Subnets
- Dockerized Flask Application
- Amazon ECR
- Amazon S3 Files Shared Storage
- Regional NAT Gateway
| Category | Technology |
|---|---|
| IaC | Terraform |
| Compute | EC2 |
| Container | Docker |
| Registry | Amazon ECR |
| Storage | Amazon S3 Files |
| Networking | VPC, ALB, NAT Gateway |
| Language | Python Flask |
app/
terraform/
Dockerfile
README.md
Public and private subnets across two Availability Zones.
Internet-facing load balancer deployed in public subnets.
Maintains EC2 instances across Availability Zones.
Runs Amazon Linux 2023 and Docker.
Mounted at /mnt/s3files and bind-mounted into the container as /app/dataset.
Provides outbound internet connectivity for private EC2 instances.
Terraform Apply → Create Networking → Create IAM → Create ALB → Create Launch Template → Create ASG → Launch EC2 → User Data → Install Docker → Mount Amazon S3 Files → Pull Image from ECR → Start Container → ALB Health Check
- Clone the repository.
- Build the Docker image.
- Push the image to Amazon ECR.
- Run
terraform init. - Run
terraform plan. - Run
terraform apply. - Wait for Auto Scaling to launch EC2 instances.
- Access the application using the ALB DNS name.
docker ps
df -h
curl localhost:5000/healthterraform destroy