This project implements a robust CI/CD pipeline for deploying a Strapi application using Blue/Green deployment strategy on AWS ECS Fargate, managed via Terraform and automated through GitHub Actions.
- Infrastructure Provisioning: Terraform
- CI/CD Pipeline: GitHub Actions
- Containerization: Docker
- Deployment Strategy: Blue/Green with AWS CodeDeploy
- Service Hosting: Amazon ECS (Fargate)
- Load Balancer: Application Load Balancer (ALB)
- Two ECS Target Groups:
blueandgreen - Application Load Balancer forwards traffic to the
blueorgreentarget group - CodeDeploy manages traffic shifting between the target groups
- VPC, Subnets, Internet Gateway, Route Tables
- Security Groups for ALB and ECS
- ALB and two target groups for blue/green
- ECS Cluster, Task Definition, and Service
- IAM Roles for ECS and CodeDeploy
- CodeDeploy App and Deployment Group configured for ECS
- Checkout repository and configure AWS credentials
- Build and push Docker image to Amazon ECR
- Register new ECS task definition with the updated image
- Create CodeDeploy deployment to trigger blue/green rollout
.github/workflows/deploy.yml- Use
AWS Consoleto monitor CodeDeploy deployments - Use
AWS CLIto query deployment status:
aws deploy list-deployments --application-name StrapiCodeDeployApp --deployment-group-name StrapiDeploymentGroup- ecsTaskExecutionRole: Allows ECS to pull from ECR and log to CloudWatch
- CodeDeployRole: Grants access to ECS, ELB, and CodeDeploy operations
- Roles and policies are defined and attached in
main.tfvia Terraform
├── .github/
│ └── workflows/
│ └── deploy.yml
├── terraform/
│ └── main.tf
├── Dockerfile
├── appspec.yaml
└── README.md
- AWS Account with programmatic access (Access Key & Secret)
- GitHub Repository with GitHub Actions enabled
- Amazon ECR Repository created for Docker images
- Terraform v1.x installed
- Docker installed locally
- Ensure IAM roles have required permissions
- Use
terraform applyto provision infrastructure - Deployments are triggered on push to
mainbranch - appspec.yaml is passed inline in the GitHub workflow
To delete all AWS resources:
terraform destroyAyush Trivedi