How m0hitd/aws-api-gateway-bluegreen works
This repository describes an AWS API Gateway blue/green deployment system. A developer push triggers a GitHub Actions rollout: Terraform manages infrastructure, a candidate is deployed to green, traffic is shifted gradually, CloudWatch alarms gate promotion, and unhealthy releases roll back. The checked-in Lambda handlers show distinct blue and green responses. Infrastructure and workflow details beyond the sampled handlers are based on the README and file tree, not inspected implementation excerpts.
Main entry points: main.tf Terraform · blue/handler.py Blue Lambda · green/handler.py Green Lambda · deploy.yml GitHub Actions
Components 17
Deployment control
- GitHub Actions
.github/workflows/deploy.yml - Terraform
terraform/main.tf - Canary deploy
scripts/canary-deploy.ps1
Request serving
- Route 53
terraform/main.tf - API Gateway
terraform/main.tf - Blue stage
terraform/main.tf - Green stage
terraform/main.tf - Blue Lambda
src/blue/handler.py - Green Lambda
src/green/handler.py - Lambda aliases
terraform/main.tf
Observability
- CloudWatch alarms
terraform/main.tf - Runtime metrics
Shared state
- DynamoDB
terraform/main.tf - Shared S3
terraform/main.tf - Terraform state
terraform/main.tf
Other components
- Developer
- Public clients
Connections 27
- Developer → GitHub Actions: pushes to main
- GitHub Actions → Terraform: applies infrastructure
- GitHub Actions → Canary deploy: orchestrates rollout
- Terraform → API Gateway: provisions
- Terraform → Blue Lambda: provisions
- Terraform → Green Lambda: provisions
- Terraform → CloudWatch alarms: configures alarms
- Terraform → DynamoDB: provisions
- Terraform → Shared S3: provisions
- Terraform → Terraform state: stores state
- Public clients → Route 53: requests service
- Route 53 → API Gateway: resolves to
- API Gateway → Blue stage: serves stage
- API Gateway → Green stage: serves stage
- Blue stage → Lambda aliases: invokes alias
- Green stage → Lambda aliases: invokes alias
- Lambda aliases → Blue Lambda: routes traffic
- Lambda aliases → Green Lambda: weights traffic
- Blue Lambda → DynamoDB: accesses shared data
- Blue Lambda → Shared S3: accesses shared data
- Green Lambda → DynamoDB: accesses shared data
- Green Lambda → Shared S3: accesses shared data
- Blue Lambda → Runtime metrics: emits
- Green Lambda → Runtime metrics: emits
- Runtime metrics → CloudWatch alarms: evaluates alarms
- Canary deploy → Lambda aliases: shifts weights
- Canary deploy → CloudWatch alarms: checks health