This project demonstrates how to build and deploy a Dockerized Flask web application to Amazon ECS (Fargate) using a fully automated CI/CD pipeline built with AWS CodePipeline, CodeBuild, and CodeDeploy.
- Language: Python 3.11 (Flask 3.0)
- Containerization: Docker
- Infrastructure:
- Amazon ECS (Fargate)
- Amazon ECR (Elastic Container Registry)
- AWS CodePipeline (CI/CD Orchestration)
- AWS CodeBuild (Image Build & Push)
- AWS CodeDeploy (Blue/Green ECS Deployment)
- Amazon S3 (Artifacts)
- GitHub / CodeCommit (Source Repo)
myapp/
├── app.py
├── Dockerfile
├── requirements.txt
├── buildspec.yml
└── imagedefinitions.json
- Code Commit:
- Code is pushed to GitHub or AWS CodeCommit.
- CodePipeline Trigger:
- Pipeline is automatically triggered.
- CodeBuild Phase:
- Builds Docker image from Dockerfile.
- Tags and pushes image to ECR.
- Generates
imagedefinitions.json
file.
- CodeDeploy Phase:
- ECS Service is updated with new image (zero-downtime Blue/Green).
- ✅ Deployed Flask App is now live on ECS Fargate!
- AWS CLI Configured
- IAM Roles:
- CodePipelineRole
- CodeBuildRole
- ECS TaskExecutionRole
- Amazon ECS Cluster & Service created with:
- Launch type: Fargate
- Container name:
myapp-container
- Amazon ECR Repo created (
myapp
) - S3 Bucket for artifacts (optional but recommended)
A simple web app using Flask 3.0:
@app.route("/")
def index():
return "✅ Deployed Flask 3.0 App via AWS ECS + CodePipeline 🚀"
---
## 🧪 Testing the App
After successful deployment, access your application via:
Application Load Balancer (ALB) DNS name
OR ECS Task public IP (if configured)
✅ Deployed Flask 3.0 App via AWS ECS + CodePipeline 🚀
## 📈 Optional Enhancements
Add unit tests to CodeBuild phase
Add CloudWatch Logs for ECS service
Configure Blue/Green Deployment with health checks
Setup GitHub Actions instead of CodeBuild for CI
Add Slack or Email Notification using SNS
## 📄 License
MIT License – free to use and modify.
## 👨💻 Author
Harsh Sonkar
AWS | Python | DevOps | Full Stack | Data Engineer