Mini Project: One Architecture, Three Clouds
Put the course together by translating a small, real-looking AWS architecture to Azure and Google Cloud. You will produce:
- a mapping table from every AWS component to its Azure and Google Cloud equivalent, with the scope of each;
- an address plan for each cloud, generated and checked by a script;
- a Terraform skeleton for each cloud (
azurermandgoogle) that expresses the same intent; - a short list of decisions where the clouds differ and you had to choose.
No cloud account is needed. If you have trial accounts, you can terraform plan (and, with a budget alert set, apply and then destroy) the skeletons; otherwise terraform init and terraform validate are enough to check them.
The AWS starting point
"shop", a small web API from the AWS Mini Project family:
Route 53 shop.example.com
│
Application Load Balancer (public subnets, 2 AZs)
│
Auto Scaling group: 2-6 × EC2 (private app subnets), IAM role "shop-api"
│ │ │
RDS PostgreSQL Multi-AZ S3 bucket "invoices" ECR repo "shop/api"
(private data subnets) (read/write by the role) (images for the ASG)
│
NAT gateway for outbound updates; CloudWatch alarm on 5xx rate; CloudTrail onVPC 10.20.0.0/16, region eu-west-1, three tiers (public, app, data) in two AZs.
Step 1: the mapping table
Fill in the table yourself first, then compare. Mark the scope on each cloud, because that's where the design changes.
| Component | AWS | Azure | Google Cloud |
|---|---|---|---|
| Container | account shop-prod |
subscription shop-prod + resource groups rg-shop-prod-{network,app,data} |
project shop-prod-XXXX (+ enabled APIs) |
| Network | VPC (regional) | VNet vnet-shop-prod (regional) |
VPC network shop-vpc (global) |
| Subnets | 6 (3 tiers × 2 AZs) | 3 (subnets span zones) + delegated snet-pg |
2 regional subnets (app, proxy-only for the regional LB) |
| Load balancer | ALB | Application Gateway (regional) or Front Door (global) | regional or global external Application Load Balancer |
| Web tier | ASG + launch template | VM Scale Set (Flexible, zones 1 2 3) + autoscale | regional MIG + instance template + autoscaler |
| App identity | IAM role + instance profile | user-assigned managed identity | service account shop-api@ |
| Database | RDS PostgreSQL Multi-AZ | PostgreSQL flexible server, zone-redundant HA, VNet-integrated | Cloud SQL PostgreSQL, REGIONAL, private IP |
| Object storage | S3 bucket | storage account (ZRS) + container invoices |
Cloud Storage bucket, regional |
| Images | ECR | ACR | Artifact Registry docker repository |
| Egress | NAT gateway per AZ | NAT Gateway on the app subnet | Cloud NAT on a Cloud Router (regional) |
| Firewall | security groups | NSGs + application security groups | firewall rules targeting service accounts |
| DNS | Route 53 | Azure DNS | Cloud DNS |
| Alarm on 5xx rate | CloudWatch alarm | Azure Monitor alert rule → action group | Cloud Monitoring alerting policy |
| Audit | CloudTrail | Activity log → Log Analytics | Cloud Audit Logs (Admin Activity on; enable Data Access for Cloud SQL and Storage) |
Step 2: the address plan
The script below generates the subnets for each cloud from one description, then checks the rules from the course: no overlaps, everything inside the network range, enough usable addresses after each cloud's reservations, and the special subnets each cloud needs.
import ipaddress
DESIGN = {
"aws": {"cidr": "10.20.0.0/16", "reserved": 5, "subnets": [
("public-a", 22), ("public-b", 22), ("app-a", 20), ("app-b", 20), ("data-a", 24), ("data-b", 24)]},
"azure": {"cidr": "10.30.0.0/16", "reserved": 5, "subnets": [
("snet-appgw", 24), ("snet-app", 20), ("snet-pg", 24), ("snet-endpoints", 26)]},
"gcp": {"cidr": "10.40.0.0/16", "reserved": 4, "subnets": [
("app-ew1", 20), ("proxy-only-ew1", 23)]},
}
NEEDS = {"app": 200} # the web tier may grow to 200 addresses per subnet
def allocate(cidr, wanted):
"""Allocate largest subnets first, each at the next free aligned address."""
vnet = ipaddress.ip_network(cidr)
taken, out = [], {}
for name, prefix in sorted(wanted, key=lambda w: w[1]):
for candidate in vnet.subnets(new_prefix=prefix):
if not any(candidate.overlaps(t) for t in taken):
taken.append(candidate)
out[name] = candidate
break
return out
for cloud, d in DESIGN.items():
plan = allocate(d["cidr"], d["subnets"])
print(f"{cloud} {d['cidr']}")
for name, net in sorted(plan.items(), key=lambda kv: kv[1]):
usable = net.num_addresses - d["reserved"]
flag = ""
if "app" in name and usable < NEEDS["app"]:
flag = " <-- too small for the web tier"
print(f" {name:<16}{str(net):<16}{usable:>6} usable{flag}")
nets = list(plan.values())
overlaps = sum(a.overlaps(b) for i, a in enumerate(nets) for b in nets[i + 1:])
print(f" overlaps: {overlaps}, all inside: {all(n.subnet_of(ipaddress.ip_network(d['cidr'])) for n in nets)}")aws 10.20.0.0/16
app-a 10.20.0.0/20 4091 usable
app-b 10.20.16.0/20 4091 usable
public-a 10.20.32.0/22 1019 usable
public-b 10.20.36.0/22 1019 usable
data-a 10.20.40.0/24 251 usable
data-b 10.20.41.0/24 251 usable
overlaps: 0, all inside: True
azure 10.30.0.0/16
snet-app 10.30.0.0/20 4091 usable
snet-appgw 10.30.16.0/24 251 usable
snet-pg 10.30.17.0/24 251 usable
snet-endpoints 10.30.18.0/26 59 usable
overlaps: 0, all inside: True
gcp 10.40.0.0/16
app-ew1 10.40.0.0/20 4092 usable
proxy-only-ew1 10.40.16.0/23 508 usable
overlaps: 0, all inside: True
Try it: shrink snet-app to /25 and watch the check fire, or add a second Google Cloud region (app-uc1) to the same /16 and confirm it still fits in one network.
Step 3: Terraform skeletons
These are skeletons: they show the shape and the key arguments, not every production setting. Put each in its own folder with its own state.
Azure (azure/main.tf, abridged):
terraform {
required_providers {
azurerm = { source = "hashicorp/azurerm", version = "~> 5.0" }
}
backend "azurerm" {
resource_group_name = "rg-tfstate"
storage_account_name = "sttfstateshop01"
container_name = "tfstate"
key = "shop/prod.tfstate"
use_azuread_auth = true
}
}
provider "azurerm" {
features {}
subscription_id = var.subscription_id
resource_providers_to_register = [
"Microsoft.Network", "Microsoft.Compute", "Microsoft.Storage",
"Microsoft.DBforPostgreSQL", "Microsoft.ContainerRegistry", "Microsoft.ManagedIdentity",
]
}
locals {
location = "westeurope"
tags = { env = "prod", app = "shop", owner = "team-checkout", "managed-by" = "terraform" }
}
resource "azurerm_resource_group" "app" {
name = "rg-shop-prod-app"
location = local.location
tags = local.tags
}
resource "azurerm_user_assigned_identity" "api" {
name = "id-shop-api"
location = local.location
resource_group_name = azurerm_resource_group.app.name
}
resource "azurerm_storage_account" "invoices" {
name = "stshopprod${var.suffix}"
resource_group_name = azurerm_resource_group.app.name
location = local.location
account_tier = "Standard"
account_replication_type = "ZRS"
min_tls_version = "TLS1_2"
shared_access_key_enabled = false
allow_nested_items_to_be_public = false
tags = local.tags
}
resource "azurerm_role_assignment" "api_blob" {
scope = azurerm_storage_account.invoices.id
role_definition_name = "Storage Blob Data Contributor"
principal_id = azurerm_user_assigned_identity.api.principal_id
}
resource "azurerm_container_registry" "shop" {
name = "acrshopprod${var.suffix}"
resource_group_name = azurerm_resource_group.app.name
location = local.location
sku = "Standard"
admin_enabled = false
}
resource "azurerm_postgresql_flexible_server" "shop" {
name = "pg-shop-prod-${var.suffix}"
resource_group_name = azurerm_resource_group.app.name
location = local.location
version = "17"
sku_name = "GP_Standard_D2ds_v5"
storage_mb = 131072
delegated_subnet_id = azurerm_subnet.pg.id
private_dns_zone_id = azurerm_private_dns_zone.pg.id
public_network_access_enabled = false
zone = "1"
administrator_login = "shopadmin"
administrator_password_wo = var.pg_admin_password
administrator_password_wo_version = 1
high_availability {
mode = "ZoneRedundant"
standby_availability_zone = "2"
}
}
# Network (vnet, subnets incl. delegated snet-pg, NAT Gateway, NSGs), the private DNS zone,
# azurerm_linux_virtual_machine_scale_set with identity { type = "UserAssigned" ... } in zones 1-3,
# azurerm_monitor_autoscale_setting, azurerm_application_gateway and azurerm_monitor_metric_alert
# follow the patterns from the earlier lessons.Google Cloud (gcp/main.tf, abridged):
terraform {
required_providers {
google = { source = "hashicorp/google", version = "~> 8.0" }
}
backend "gcs" {
bucket = "shop-tfstate-4821"
prefix = "shop/prod"
}
}
provider "google" {
project = var.project_id
region = "europe-west1"
}
locals {
labels = { env = "prod", app = "shop", owner = "team-checkout", "managed-by" = "terraform" }
}
resource "google_project_service" "apis" {
for_each = toset([
"compute.googleapis.com", "sqladmin.googleapis.com", "servicenetworking.googleapis.com",
"artifactregistry.googleapis.com", "storage.googleapis.com",
])
service = each.value
}
resource "google_service_account" "api" {
account_id = "shop-api"
display_name = "shop API"
}
resource "google_storage_bucket" "invoices" {
name = "shop-prod-invoices-${var.suffix}"
location = "europe-west1"
uniform_bucket_level_access = true
public_access_prevention = "enforced"
labels = local.labels
}
resource "google_storage_bucket_iam_member" "api_objects" {
bucket = google_storage_bucket.invoices.name
role = "roles/storage.objectUser"
member = "serviceAccount:${google_service_account.api.email}"
}
resource "google_artifact_registry_repository" "shop" {
location = "europe-west1"
repository_id = "shop"
format = "DOCKER"
depends_on = [google_project_service.apis]
}
resource "google_sql_database_instance" "shop" {
name = "pg-shop-prod"
database_version = "POSTGRES_17"
region = "europe-west1"
settings {
edition = "ENTERPRISE"
tier = "db-custom-2-8192"
availability_type = "REGIONAL"
ip_configuration {
ipv4_enabled = false
private_network = google_compute_network.shop.id
}
backup_configuration {
enabled = true
point_in_time_recovery_enabled = true
}
}
deletion_protection = true
depends_on = [google_service_networking_connection.psa]
}
# Network (google_compute_network custom mode, subnets, router + NAT, firewall rules targeting
# the service account, incl. health-check ranges), private services access
# (google_compute_global_address + google_service_networking_connection),
# google_compute_region_instance_template, google_compute_region_instance_group_manager,
# google_compute_region_autoscaler, the load balancer and google_monitoring_alert_policy
# follow the patterns from the earlier lessons.Once you have added the resources sketched in the comments and declared the variables (subscription_id, project_id, suffix, pg_admin_password), check each folder with:
terraform -chdir=azure init -backend=false && terraform -chdir=azure validate
terraform -chdir=gcp init -backend=false && terraform -chdir=gcp validate(init downloads the providers, so it needs network access; -backend=false skips the remote state so no credentials are needed.)
Step 4: decisions to write down
Write two or three sentences for each; there's no single right answer, but there should be a reason:
- Regional or global entry point? Application Gateway vs Front Door on Azure; regional vs global Application Load Balancer on Google Cloud. What does the AWS design actually need?
- VMs or serverless containers? The ASG could become Container Apps or Cloud Run with far less to run. What would you lose (SSH, OS-level agents) and gain?
- Database private access model: VNet integration vs private endpoint on Azure (chosen at creation, can't switch); private services access vs Private Service Connect on Google Cloud.
- Identity for CI: the federated credentials and workload identity pool you'd create for the deploy pipeline (Federation), and exactly which subjects or attributes they trust.
- Guardrails: which three policies you'd assign above the subscription or project on day one.
Checklist
- Mapping table complete, with scopes.
- Address plan passes the checks for all three clouds.
- Both completed skeletons pass
terraform validate. - No secrets in code: the database password comes from a variable fed by Key Vault / Secret Manager, or is replaced by Entra ID / IAM database authentication.
- Every resource carries the
env,app,ownertags or labels. - Decisions written down.
- If you applied anything:
terraform destroyrun, budget alerts checked, nothing left running.
Test yourself
The AWS design has 6 subnets (3 tiers × 2 AZs). Why does the Azure plan have a different count?
- Azure has fewer tiers
- Azure subnets span zones, and some services need dedicated or delegated subnets
- Azure has no private subnets
- It's a mistake
Which Terraform resource gives the Google Cloud API service account access to just the invoices bucket?
- google_project_iam_policy
- google_storage_bucket_iam_member
- google_service_account_key
- google_project_service
Why does the Google Cloud database depend on google_service_networking_connection?
- For billing
- Private IP Cloud SQL needs private services access set up on the VPC first
- To enable backups
- It doesn't need it