This project demonstrates a production-grade multi-cloud DevOps architecture deployed across AWS and GCP using:
- FastAPI Backend
- Next.js Frontend
- Terraform (Infrastructure as Code)
- GitLab CI/CD
- Multi-environment setup (Dev, Staging, Prod)
- Secure authentication mechanisms (IAM & OIDC)
The focus of this implementation is scalability, security, automation, and operational reliability.
- VPC (Public & Private Subnets)
- Internet Gateway
- NAT Gateway
- Application Load Balancer (ALB)
- ECS Fargate Services (Frontend & Backend)
- Auto Scaling Policies (CPU-based)
- IAM Execution Roles
- Rolling deployments (Zero downtime)
User โ ALB (Public Subnet)
ALB routes:
/api/*โ Backend Service/โ Frontend Service
ECS tasks run in Private Subnets
NAT Gateway enables outbound internet access
- VPC
- Managed Instance Groups (Frontend & Backend)
- Instance Templates
- HTTP Load Balancer
- Health Checks
- Workload Identity Federation (OIDC)
User โ GCP Load Balancer โ MIG Instances
MIG maintains desired instance count
Rolling restart ensures zero downtime
Infra/
aws/
environments/
dev/
staging/
prod/
gcp/
environments/
dev/
staging/
prod/
Each environment has isolated Terraform state and configuration.
Each environment includes:
- Separate Terraform configuration
- Isolated remote state
- Unique resource naming
- Independent scaling configuration
This prevents cross-environment impact and protects production systems.
- IAM Execution Roles for ECS tasks
- IAM user credentials stored as protected GitLab variables
- No hardcoded secrets in repository
- Least privilege access policies
- No Service Account JSON keys used
- GitLab OIDC โ GCP Workload Identity Federation
- Short-lived temporary credentials
- Secure token exchange via STS
Pipeline is fully parameterized and controlled using variables.
Navigate to:
GitLab โ Settings โ CI/CD โ Variables
| Variable | Values |
|---|---|
CLOUD |
aws / gcp |
ENVIRONMENT |
dev / staging / prod |
ACTION |
infra / deploy / destroy |
| Variable | Description |
|---|---|
AWS_ACCESS_KEY_ID |
IAM access key |
AWS_SECRET_ACCESS_KEY |
IAM secret key |
AWS_DEFAULT_REGION |
ap-south-1 |
These are stored as protected & masked variables.
| Variable | Example |
|---|---|
GCP_PROJECT_ID |
your-project-id |
GCP_PROJECT_NUMBER |
123456789012 |
GCP_SERVICE_ACCOUNT_EMAIL |
[email protected] |
GCP_WORKLOAD_IDENTITY_PROVIDER |
projects/PROJECT_NUMBER/locations/global/workloadIdentityPools/POOL/providers/PROVIDER |
- GitLab job generates short-lived OIDC token
- Token is exchanged with GCP Security Token Service
- GCP issues temporary credentials
- Terraform and gcloud run securely
No static keys are stored anywhere.
ACTION=infra
CLOUD=aws or gcp
ENVIRONMENT=dev/staging/prod
Runs:
- terraform validate
- terraform plan
- manual terraform apply
ACTION=deploy
Runs:
- Docker image build
- Push to DockerHub
- Rolling deployment
AWS:
- ECS force new deployment
GCP:
- MIG rolling restart
ACTION=destroy
Manual confirmation required.
- ECS rolling updates
- ALB health checks
- Auto scaling enabled
- Multi-AZ deployment
- MIG rolling-action restart
- Health check validation
- Auto-healing instances
- Remote backend storage (S3 for AWS / GCS for GCP)
- State locking enabled
- Environment-specific state isolation
- Prevents drift and concurrent modification
- ECS tasks use IAM Task Execution Role
- No credentials inside containers
- Secure image pulls from DockerHub
- Infrastructure authenticated via OIDC
- Runtime VMs use attached Service Account
- No embedded credentials in instance templates
| Scenario | Handling |
|---|---|
| Container crash | ECS auto-restart |
| Instance crash | MIG auto-healing |
| High CPU | Auto scaling |
| Failed deployment | Health checks block traffic |
| Network outage | Multi-AZ resilience |
- Kubernetes (EKS / GKE)
- Blue-Green deployment
- Canary releases
- CDN integration
- Observability stack (Prometheus/Grafana)
- Centralized logging
- Multi-region disaster recovery
- Modular Terraform architecture
- Multi-cloud deployment strategy
- Environment isolation
- CI/CD parameterization
- OIDC-based authentication
- Zero downtime deployment
- Secure secret management
- Infrastructure & application separation
- Auto scaling & health checks
- Production-grade operational thinking
Saravana L
DevOps Engineer
LinkedIn: https://linkedin.com/in/saravanal
โญ If you found this project interesting, feel free to connect with me!