🎯 Problem Statement

Enterprise organizations face several challenges with cloud infrastructure:

  • Vendor Lock-in - Over-reliance on a single cloud provider
  • Disaster Recovery - Need for geographic and provider redundancy
  • Compliance - Data residency requirements across regions
  • Cost Optimization - Leveraging best pricing across providers
  • Complexity - Managing infrastructure across multiple platforms

πŸ’‘ Solution Overview

I architected and implemented a multi-cloud infrastructure spanning Azure and GCP using Terraform, providing high availability, disaster recovery, and cost optimization while maintaining a unified Infrastructure as Code approach.

πŸ—οΈ Architecture

β”Œβ”‚β”‚β””β”Œβ”‚β”‚β”œβ”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Œβ”‚β”‚β””β”€β”€β”€β”€β”€β”Œβ”‚β””β”Œβ”‚β–Όβ”€β”€β”Œβ”‚β”‚β””β”Œβ”‚β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€W──────────────e──────────────As──────────────Kt─│└─(──A(──────────S───G──zR──────────E───Ae──uA─────(──A───U───zo──r-─────P──z──────u-──eG─────Ar──uβ”€β”€β”β”‚β”‚β”˜β”€β”€rR──R─────Zi──r────ee──BS─────Um──e────p──l)─────Ra───│┴──Dl──o─────Er──F────ai──b─────y──r──┬│┴tc───────)──o────aa──S───────n────bt──t────│▼───t────ae──oβ”€β”€β”‚β””β”Œβ”‚β”‚β””β”€β”€β”€β”€β”€β”€β”€β”€β”€sd──r──────────Dβ”€β”€β”Œβ”‚β”‚β””β”€β”€e)──a──────────o────────g──────────o───E─────e────(──(────r───a─────────P──A───────As─────────Cr──Gz─────┐│▼─Ktβ”€β”‚β”˜β”€β”€β”€β”€β”€β”€β”€eo──lu──────S────────nm──or──────U────────te──be──────S────────rt──aβ”€β”€β”€β”€β”€β”€β”€β”β”‚β”‚β”˜β”β”‚β”‚β”˜β”€β”€β”€ah──lTβ”€β”€β”€β”β”‚β”˜β”β”‚β”‚β”˜β—„β—„β”€β”€β”€le──r────────iu──Taβ”€β”β”€β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”Όβ”‚β”‚β”Όβ”‚β”‚β”˜β”€β”€zs──rf─│││─│───e──af───┬▼─d+──fi───────fcβ”€β”Œβ”œβ”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”Όβ”‚β”‚β”Όβ”‚β”‚β””β”€β”€MG──i──││─│─│────or──cMβ”€β”€β”€β”Œβ”‚β”‚β””β”€β”€β”€β”€β”€na──aβ”€β”€β”€β”Œβ”‚β””β”Œβ”‚β–Όβ”€β”€β”Œβ”‚β”‚β””β”Œβ”‚β”‚β””β”€β”€β”€if──Mn───────────────ta──aa───────E────────on──ng───────GU────────ra──ae───────K─│└─(──C(────i──gr────C───E───C──lM────n+──e────l──────r──ou────g──r/────o──────Co──ul────P────(──u──────ls──dt────a──C──S──dβ”€β”€β”β”‚β”‚β”˜β”€β”€os──i────g──l──e──────u-──S-────e──o──Gc──L────dR──tR────r──u──Co──o─┴──e──oe────D──d──Pn──a─│───Sg──rg────u────d──d──┬│┴Qi──ai────t──D─│▼─a──────Lo──goβ”€β”€β”‚β”˜β”β”‚yβ”˜β”€N──r──B────n──en──)─S──y──a────)──a──│─)──)──l──────l───────aβ”€β”€β”Œβ”‚β”‚β””β”€β”€β”€β”€)───────n───────────────c───────────────e───U────────────r───GS─────────────┐│▼─Kβ”€β”‚β”˜β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€Eβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”‚β”€β”€β”€β”β”‚β”‚β”˜β”β”‚β”‚β”˜β”€β”€β”€β”€β”€β”β”˜β”β”‚β”‚β”˜β”€β”€β”€β”€β”€β”‚β”€β”€β”€β”β”€β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”‚β”˜β”€β”€β”€β”€β”‚β”‚β”‚β”‚β”€β”€β”€β”€β”€β”€β”β”˜β”‚β”‚

πŸ› οΈ Technologies Used

CategoryAzureGCP
ComputeAKSGKE
Load BalancingAzure Front DoorCloud Load Balancer
DatabaseAzure PostgreSQLCloud SQL
StorageBlob Storage (RA-GRS)Cloud Storage
DNSTraffic ManagerCloud DNS
SecretsKey VaultSecret Manager
MonitoringAzure MonitorCloud Monitoring

Common Tools:

  • Terraform 1.5+ with workspaces
  • Terragrunt for DRY configurations
  • GitHub Actions for CI/CD
  • Prometheus + Grafana (multi-cloud)

πŸ“ Project Structure

mβ”œβ”‚β”‚β”‚β”œβ”‚β”‚β”‚β”œβ””u────l────timβ”œβ”œβ””eβ”œβ”œβ””tRco───n───eEld───v───rAouirDulagsrdspaMdezchoetrgE-supanvaor.t/r/rm/gdumeeeei/ndr/dnntr/tg.as/hf/colrm/######AGDDSPKKNetrSESvao,,,gdciunnmonceeongtttnfiwwiicoootgonrrosnkkrfciii(ionnnagngggzsf,,uirgddesaa/tt,aabbgaacsspee/,,)ssttoorraaggee

πŸ”§ Implementation Highlights

Unified Terraform Module Pattern

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# modules/kubernetes/main.tf
# Abstract module that works across cloud providers

variable "cloud_provider" {
  type        = string
  description = "Cloud provider: azure or gcp"
  validation {
    condition     = contains(["azure", "gcp"], var.cloud_provider)
    error_message = "Must be azure or gcp."
  }
}

variable "cluster_config" {
  type = object({
    name         = string
    node_count   = number
    node_size    = string
    k8s_version  = string
  })
}

module "aks" {
  source = "../azure/aks"
  count  = var.cloud_provider == "azure" ? 1 : 0
  
  cluster_name = var.cluster_config.name
  node_count   = var.cluster_config.node_count
  vm_size      = var.cluster_config.node_size
  k8s_version  = var.cluster_config.k8s_version
}

module "gke" {
  source = "../gcp/gke"
  count  = var.cloud_provider == "gcp" ? 1 : 0
  
  cluster_name  = var.cluster_config.name
  node_count    = var.cluster_config.node_count
  machine_type  = var.cluster_config.node_size
  gke_version   = var.cluster_config.k8s_version
}

Cross-Cloud Data Replication

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
# Database replication setup
resource "azurerm_postgresql_flexible_server" "primary" {
  name                = "db-primary"
  resource_group_name = azurerm_resource_group.main.name
  location            = "westeurope"
  
  sku_name   = "GP_Standard_D4s_v3"
  storage_mb = 32768
  version    = "14"
  
  high_availability {
    mode = "ZoneRedundant"
  }
  
  # Cross-cloud replication via logical replication
  # Configured through application-level sync
}

Terragrunt DRY Configuration

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# environments/prod/azure/terragrunt.hcl
include "root" {
  path = find_in_parent_folders()
}

terraform {
  source = "../../../modules/azure/aks"
}

inputs = {
  environment     = "prod"
  cluster_name    = "aks-prod-westeu"
  node_count      = 5
  node_pool_min   = 3
  node_pool_max   = 10
  vm_size         = "Standard_D4s_v5"
  
  tags = {
    Environment = "Production"
    ManagedBy   = "Terraform"
    CostCenter  = "Platform"
  }
}

πŸ” Security Implementation

  • Network Isolation - VNet/VPC peering with strict firewall rules
  • Zero Trust - Service mesh with mTLS (Istio)
  • Identity Federation - Azure AD ↔ Google Workspace
  • Encryption - Data encrypted at rest and in transit
  • Compliance - SOC2, GDPR-ready architecture
  • Secret Management - HashiCorp Vault for cross-cloud secrets

πŸ“Š Results & Benefits

MetricAchievement
Availability99.99% uptime
RTO< 5 minutes
RPO< 1 minute
Cost Savings25% via spot/preemptible instances
Deployment Consistency100% across clouds

πŸ”‘ Key Learnings

  1. Abstraction is Key - Creating provider-agnostic modules reduces complexity
  2. State Management - Separate state files per cloud prevent blast radius issues
  3. Testing - Terratest for automated infrastructure testing across clouds
  4. Documentation - Comprehensive runbooks for cross-cloud failover scenarios
  5. Cost Monitoring - Unified cost dashboards essential for multi-cloud optimization

⚠️ Challenges Overcome

  • Service Parity - Not all services have direct equivalents; designed for lowest common denominator
  • Networking - VPN tunnels between clouds for private connectivity
  • Monitoring - Unified observability stack (Prometheus) vs native tools
  • Team Skills - Cross-training team on both cloud platforms

πŸ”— Resources


Building multi-cloud? Let’s connect!