CI-CD-Pipeline-for-Dockerized-Web-App-on-AWS-ECS-using-CodePipeline

๐Ÿš€ AWS CI/CD Deployment โ€“ Flask App on ECS with CodePipeline

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.


๐Ÿ”ง Tech Stack


๐Ÿ“ Project Structure

myapp/

โ”œโ”€โ”€ app.py
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ requirements.txt
โ”œโ”€โ”€ buildspec.yml
     โ””โ”€โ”€ imagedefinitions.json 


๐Ÿšฆ CI/CD Pipeline Flow

  1. Code Commit:
    • Code is pushed to GitHub or AWS CodeCommit.
  2. CodePipeline Trigger:
    • Pipeline is automatically triggered.
  3. CodeBuild Phase:
    • Builds Docker image from Dockerfile.
    • Tags and pushes image to ECR.
    • Generates imagedefinitions.json file.
  4. CodeDeploy Phase:
    • ECS Service is updated with new image (zero-downtime Blue/Green).
  5. โœ… Deployed Flask App is now live on ECS Fargate!

๐Ÿ“ฆ Requirements


๐Ÿ” Key Files

app.py

A simple web app using Flask 3.0:

```python @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