Skip to content

trivediayush/Strapi-Task10

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Strapi Blue/Green Deployment on AWS ECS using CodeDeploy and GitHub Actions

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.

🚀 Overview

  • 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)

📦 Architecture

  • Two ECS Target Groups: blue and green
  • Application Load Balancer forwards traffic to the blue or green target group
  • CodeDeploy manages traffic shifting between the target groups

🛠️ Terraform Components

  • 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

⚙️ GitHub Actions Workflow

  1. Checkout repository and configure AWS credentials
  2. Build and push Docker image to Amazon ECR
  3. Register new ECS task definition with the updated image
  4. Create CodeDeploy deployment to trigger blue/green rollout

Sample Workflow Path

.github/workflows/deploy.yml

🧪 Deployment Monitoring

  • Use AWS Console to monitor CodeDeploy deployments
  • Use AWS CLI to query deployment status:
aws deploy list-deployments --application-name StrapiCodeDeployApp --deployment-group-name StrapiDeploymentGroup

🔐 IAM Roles & Policies

  • 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.tf via Terraform

📁 File Structure


├── .github/
│   └── workflows/
│       └── deploy.yml
├── terraform/
│   └── main.tf
├── Dockerfile
├── appspec.yaml
└── README.md

✅ Prerequisites

  • 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

📌 Notes

  • Ensure IAM roles have required permissions
  • Use terraform apply to provision infrastructure
  • Deployments are triggered on push to main branch
  • appspec.yaml is passed inline in the GitHub workflow

📖 References

🧹 Cleanup

To delete all AWS resources:

terraform destroy

👤 Author

Ayush Trivedi

About

This repository embodies a production-grade DevOps implementation for deploying a Strapi-based application on AWS using a Blue/Green deployment strategy. It demonstrates a fully automated CI/CD lifecycle, integrating infrastructure provisioning, containerisation, and deployment orchestration within a scalable cloud-native architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors