A production-ready, fully automated CI/CD pipeline built on AWS using Terraform, featuring containerized deployment with ECS Fargate, automated builds with CodePipeline, and a modern responsive web interface.
- Overview
- Architecture
- Features
- Prerequisites
- Quick Start
- Project Structure
- CI/CD Pipeline
- Contributing
- License
- Acknowledgments
This project demonstrates a complete AWS DevOps pipeline that automatically builds, tests, and deploys a Node.js application to ECS Fargate whenever code is pushed to GitHub. Everything is provisioned using Infrastructure as Code (Terraform) following AWS best practices.
- Application URL: Provided after
terraform applycompletes - CodePipeline Console:
https://console.aws.amazon.com/codesuite/codepipeline/pipelines/aws-devops-pipeline/view
- VPC: Isolated network with public/private subnets across 2 AZs
- ECS Fargate: Serverless container orchestration
- Application Load Balancer: Traffic distribution with health checks
- ECR: Private Docker image registry
- CodePipeline: Automated CI/CD workflow
- CodeBuild: Docker image building
- CloudWatch: Centralized logging and monitoring
- ✅ Multi-AZ Deployment - High availability across availability zones
- ✅ Auto-scaling - Scales from 2-4 tasks based on CPU/Memory
- ✅ Zero-downtime Deployments - Rolling updates with circuit breaker
- ✅ Infrastructure as Code - 100% Terraform-managed
- ✅ Automated Backups - S3 artifact storage with lifecycle policies
- ✅ Automated Builds - Triggered on every GitHub push
- ✅ Docker Multi-stage Builds - Optimized image size
- ✅ Vulnerability Scanning - ECR image scanning on push
- ✅ Deployment Circuit Breaker - Automatic rollback on failures
- ✅ Build Caching - Faster builds with npm cache
- ✅ Modern UI - Responsive design with dark theme
- ✅ Mobile-friendly - Hamburger menu for mobile devices
- ✅ Health Checks - Application and container-level monitoring
- ✅ Graceful Shutdown - Proper signal handling
- ✅ Security Headers - Helmet.js for HTTP security
- ✅ Least Privilege IAM - Minimal required permissions
- ✅ Private Subnets - Containers run in private network
- ✅ Security Groups - Strict ingress/egress rules
- ✅ Non-root Containers - Enhanced container security
- ✅ Secrets Management - GitHub token via Terraform variables
- AWS CLI (v2.x) - Install Guide
- Terraform (v1.0+) - Install Guide
- Git
- Node.js (v18+) - For local development (optional)
- Docker - For local testing (optional)
- Active AWS account with admin access
- AWS credentials configured (
aws configure) - GitHub Personal Access Token with
repoandadmin:repo_hookpermissions
git clone https://github.com/Amitabh-DevOps/aws-devops.git
cd aws-devopsaws configure
# Enter your AWS Access Key ID
# Enter your AWS Secret Access Key
# Default region: us-east-1
# Default output format: json- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Generate new token with scopes:
repoandadmin:repo_hook - Copy the token (you'll need it in the next step)
cd terraform
cp terraform.tfvars.example terraform.tfvarsEdit terraform.tfvars:
aws_region = "us-east-1"
project_name = "aws-devops"
github_repo = "YourUsername/aws-devops" # Change this!
github_branch = "main"
github_token = "ghp_your_token_here" # Paste your token!# Initialize Terraform
terraform init
# Validate the configuration
terraform validate
# Review the execution plan
terraform plan
# Apply the configuration with auto-approve
terraform apply --auto-approveDeployment takes ~5-10 minutes
After deployment completes, Terraform will output:
Outputs:
alb_url = "http://aws-devops-alb-xxxxx.us-east-1.elb.amazonaws.com/"
codepipeline_url = "https://console.aws.amazon.com/codesuite/codepipeline/..."
ecr_repository_url = "xxxxx.dkr.ecr.us-east-1.amazonaws.com/aws-devops-app"
Visit the alb_url to see your application! 🎉
aws-devops/
├── app/ # Node.js Application
│ ├── src/
│ │ └── server.js # Express server
│ ├── public/
│ │ ├── index.html # Frontend UI
│ │ ├── css/style.css # Responsive styles
│ │ └── js/app.js # Client-side JavaScript
│ ├── Dockerfile # Multi-stage Docker build
│ ├── buildspec.yml # CodeBuild configuration
│ ├── package.json # Node.js dependencies
│ └── .dockerignore # Docker build exclusions
│
├── terraform/ # Infrastructure as Code
│ ├── main.tf # Provider & data sources
│ ├── variables.tf # Input variables
│ ├── outputs.tf # Output values
│ ├── vpc.tf # VPC, subnets, NAT, IGW
│ ├── ecr.tf # Container registry
│ ├── ecs.tf # ECS cluster, service, ALB
│ ├── iam.tf # IAM roles & policies
│ ├── codebuild.tf # Build project
│ ├── codepipeline.tf # CI/CD pipeline
│ ├── terraform.tfvars.example # Example variables
│ └── .gitignore # Terraform exclusions
│
├── README.md # This file
├── LICENSE # MIT License
└── .gitignore # Git exclusions
cd app
# Install dependencies
npm install
# Run development server
npm run dev
# Access at http://localhost:3000cd app
# Build image
docker build -t aws-devops-app .
# Run container
docker run -p 3000:3000 aws-devops-app
# Access at http://localhost:3000- Source - Pulls code from GitHub on push
- Build - CodeBuild builds Docker image and pushes to ECR
- Deploy - Updates ECS service with new image
# buildspec.yml
phases:
pre_build:
- Login to ECR
- Set image tag from commit hash
build:
- Build Docker image
- Tag with commit hash and 'latest'
post_build:
- Push images to ECR
- Generate imagedefinitions.json# Make code changes
git add .
git commit -m "Update feature"
git push origin main
# Pipeline automatically triggers!- Go to CloudWatch Console:
/ecs/aws-devops- Application logs/aws/codebuild/aws-devops- Build logs
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- AWS for comprehensive cloud services
- HashiCorp for Terraform
- The open-source community
Built with ❤️ for DevOps by Amitabh
⭐ Star this repo if you find it helpful!










