Skip to content

SaravanaNani/DevOps-Assignment-PGAGI

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

60 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ DevOps Multi-Cloud Infrastructure & CI/CD Pipeline

๐Ÿ“Œ Overview

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.


๐Ÿ— Architecture Overview

โ˜๏ธ AWS Architecture

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

Traffic Flow

User โ†’ ALB (Public Subnet)
ALB routes:

  • /api/* โ†’ Backend Service
  • / โ†’ Frontend Service
    ECS tasks run in Private Subnets
    NAT Gateway enables outbound internet access

๐ŸŒ GCP Architecture

  • VPC
  • Managed Instance Groups (Frontend & Backend)
  • Instance Templates
  • HTTP Load Balancer
  • Health Checks
  • Workload Identity Federation (OIDC)

Traffic Flow

User โ†’ GCP Load Balancer โ†’ MIG Instances
MIG maintains desired instance count
Rolling restart ensures zero downtime


๐ŸŒ Environment Structure

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.


๐Ÿ” Security Model

AWS

  • IAM Execution Roles for ECS tasks
  • IAM user credentials stored as protected GitLab variables
  • No hardcoded secrets in repository
  • Least privilege access policies

GCP

  • No Service Account JSON keys used
  • GitLab OIDC โ†’ GCP Workload Identity Federation
  • Short-lived temporary credentials
  • Secure token exchange via STS

โš™๏ธ GitLab CI/CD Setup

Pipeline is fully parameterized and controlled using variables.

Required GitLab Variables

Navigate to:

GitLab โ†’ Settings โ†’ CI/CD โ†’ Variables


๐ŸŒ Common Variables

Variable Values
CLOUD aws / gcp
ENVIRONMENT dev / staging / prod
ACTION infra / deploy / destroy

โ˜๏ธ AWS Variables

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.


๐ŸŒ GCP Variables (OIDC Setup)

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

๐Ÿ”„ How GCP OIDC Works

  1. GitLab job generates short-lived OIDC token
  2. Token is exchanged with GCP Security Token Service
  3. GCP issues temporary credentials
  4. Terraform and gcloud run securely

No static keys are stored anywhere.


๐Ÿ” Pipeline Execution Flow

๐Ÿ— Infrastructure Provisioning

ACTION=infra
CLOUD=aws or gcp
ENVIRONMENT=dev/staging/prod

Runs:

  • terraform validate
  • terraform plan
  • manual terraform apply

๐Ÿš€ Application Deployment

ACTION=deploy

Runs:

  • Docker image build
  • Push to DockerHub
  • Rolling deployment

AWS:

  • ECS force new deployment

GCP:

  • MIG rolling restart

๐Ÿงจ Destroy Infrastructure


ACTION=destroy

Manual confirmation required.


๐Ÿš€ Zero Downtime Strategy

AWS

  • ECS rolling updates
  • ALB health checks
  • Auto scaling enabled
  • Multi-AZ deployment

GCP

  • MIG rolling-action restart
  • Health check validation
  • Auto-healing instances

๐Ÿง  Infrastructure State Management

  • Remote backend storage (S3 for AWS / GCS for GCP)
  • State locking enabled
  • Environment-specific state isolation
  • Prevents drift and concurrent modification

๐Ÿ›ก Worker Node & Runtime Authentication

AWS

  • ECS tasks use IAM Task Execution Role
  • No credentials inside containers
  • Secure image pulls from DockerHub

GCP

  • Infrastructure authenticated via OIDC
  • Runtime VMs use attached Service Account
  • No embedded credentials in instance templates

๐Ÿ“Š Failure Handling Strategy

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

๐Ÿ”ฎ Future Improvements

  • Kubernetes (EKS / GKE)
  • Blue-Green deployment
  • Canary releases
  • CDN integration
  • Observability stack (Prometheus/Grafana)
  • Centralized logging
  • Multi-region disaster recovery

๐ŸŽฏ DevOps Concepts Demonstrated

  • 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

๐Ÿ‘จโ€๐Ÿ’ป Author

Saravana L
DevOps Engineer
LinkedIn: https://linkedin.com/in/saravanal


โญ If you found this project interesting, feel free to connect with me!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • HCL 89.0%
  • JavaScript 6.4%
  • Shell 1.6%
  • Dockerfile 1.6%
  • Python 1.4%