A company wants to move the orders platform to the cloud for under USD 2,000 a month. The first design has realistic mistakes. You review it as data against the well-architected pillars, fix it, review again, and check the cost, recovery, and sustainability numbers.
Accounts or projects per environment, federated identity, no long-lived keys, least privilege.
Lessons: Landing Zones: Account Hierarchy, Identity Federation, and Guardrails, Proving Who You Are, Then What You May Do
Non-overlapping address ranges, private subnets for workloads, and a hub for shared services.
Lessons: Hub-and-Spoke, Transit Networking, and Private Service Access, CIDR Notation and CIDR Calculations
Central logs, tags for owner and cost centre, and policies that enforce them.
Lessons: Cloud Governance, Policy as Code, and Automated Architecture Reviews
Recovery point and time objectives, and whether the design can meet them.
Lessons: Disaster Recovery Setup, Multi-Region Architecture: Active/Active, Active/Passive, RTO, and RPO
A monthly estimate against the budget, and the right-sizing that brings it under.
Lessons: FinOps, Cloud Cost Optimization, Sustainability Engineering: Measuring and Cutting the Carbon of Software
Each finding names its pillar and its fix; the fixed design passes with no findings.
Lessons: Well-Architected Pillars: Judging the Design You Just Built, Design Docs, ADRs, and Design Reviews: Writing the Decision Down
| Tool | Version |
|---|---|
| python3 | 3.10 or later |
Ports: none. Resources: Under 50 MB; no cloud account, standard library only.
What it creates (and the reset removes): ~/labs/capstones/cloud (landing-zone.json and the review). Every name starts with cap- or lives under ~/labs/capstones, so nothing of yours is changed. The scripts stop with a clear message if a tool is missing or a port is taken.
One archive holds every capstone and the shared service. Read a script before you run it; the main ones are shown below.
mkdir -p ~/labs && cd ~/labs curl -fsSLO https://mohankrishnapodile.com/capstones/capstones-lab.tar.gz tar -xzf capstones-lab.tar.gz && cd capstones-lab ls
All in one, with the reset afterwards even if a step fails:
bash run.sh 10-cloud-architecture
Or one step at a time, to look around between them (add KEEP=1 before bash run.sh to keep it running after verify):
python3 10-cloud-architecture/review.py setup python3 10-cloud-architecture/review.py verify python3 10-cloud-architecture/review.py reset
This is a real run of run.sh 10-cloud-architecture, recorded when the page was built. Digests, timings, and random values differ on your machine; every check should still say PASS, and the last line should say all checks passed.
landing-zone.json written: 4 accounts, 2 workloads, a hub-and-spoke network; review it with verify == First review [security] payments runs in production and dev: one workload, one environment per account [security] the root or owner login has no MFA [security] 3 users have long-lived access keys: use SSO and short-lived roles [security] role deployer allows every action on every resource [reliability] address ranges overlap: prod 10.1.0.0/16 and dev 10.1.128.0/17 [security] subnet prod-db holds databases but is public [operational excellence] orders is missing tags: cost-center, data-class [operational excellence] orders lacks traces [reliability] orders: backups every 24 h cannot meet a tier-1 RPO of 0.25 h [reliability] orders: no backup copy outside its region [reliability] orders: last restore test 400 days ago (more than 90) [reliability] orders: DR strategy backup-restore gives RTO 12 h; tier 1 needs 1 h [sustainability] orders runs in region-b (430 gCO2e/kWh, illustrative); a lower-carbon region exists [sustainability] payments runs in region-b (430 gCO2e/kWh, illustrative); a lower-carbon region exists [cost optimization] estimated USD 2,264 a month exceeds the budget of USD 2,000 PASS 15 findings across 5 pillars estimated cost: USD 2,263.86 a month (budget USD 2,000) == Fixes applied (as a reviewed change to landing-zone.json), then review again PASS the second review has 0 findings PASS cost after rightsizing: USD 1,938.49 a month, within budget, including the warm standby PASS every tier-1 workload meets its RTO and RPO PASS no address ranges overlap RESULT: all checks passed
10-cloud-architecture/expected-output.txt10-cloud-architecture/review.pylib.sh (shared helpers)app/orders.py (the service)10-cloud-architecture/review.py#!/usr/bin/env python3
"""Capstone 10, cloud architecture: landing zone -> IAM -> network -> workload isolation ->
observability -> governance -> backup -> disaster recovery -> cost controls -> sustainability.
The architecture is described as data (landing-zone.json) and reviewed by automated checks, the
way an architecture review board or a policy pipeline would. setup writes a first design with
realistic mistakes; verify reviews it, applies the fixes, reviews again, and checks the result.
Provider specifics (AWS, Azure, Google Cloud) are mapped on the capstone page and not run here.
python3 review.py setup | verify | reset
"""
import copy
import ipaddress
import json
import os
import shutil
import sys
WORK = os.path.expanduser("~/labs/capstones/cloud")
FAILS = []
REQUIRED_TAGS = {"owner", "cost-center", "environment", "data-class"}
PRICE = {"vm.small": 30.37, "vm.medium": 60.74, "vm.large": 121.47, "db.medium": 146.0, "db.large": 292.0, "storage.gb": 0.023, "nat": 32.85, "log.gb": 0.5}
CARBON = {"region-a": 120, "region-b": 430, "region-c": 35} # illustrative gCO2e per kWh
TIER = {1: {"rto_h": 1, "rpo_h": 0.25}, 2: {"rto_h": 8, "rpo_h": 4}, 3: {"rto_h": 24, "rpo_h": 24}}
def p(*x): return os.path.join(WORK, *x)
def ok(m): print(" PASS ", m)
def bad(m): FAILS.append(m); print(" FAIL ", m)
FIRST = {
"org": {"accounts": [
{"name": "management", "purpose": "billing and policies only", "workloads": []},
{"name": "shared", "purpose": "network hub, logging, security tooling", "workloads": []},
{"name": "prod", "purpose": "production", "workloads": ["orders", "payments"]},
{"name": "dev", "purpose": "development", "workloads": ["orders-dev", "payments"]}]},
"identity": {"sso": True, "root_mfa": False, "users_with_access_keys": 3,
"roles": [{"name": "deployer", "actions": ["*"], "resources": ["*"]}, {"name": "reader", "actions": ["ec2:Describe*"], "resources": ["*"]}]},
"network": {"hub": "10.0.0.0/16", "spokes": {"prod": "10.1.0.0/16", "dev": "10.1.128.0/17"}, "onprem": ["192.168.0.0/16"],
"subnets": [{"name": "prod-db", "cidr": "10.1.20.0/24", "public": True}, {"name": "prod-app", "cidr": "10.1.10.0/24", "public": False}]},
"workloads": [
{"name": "orders", "account": "prod", "tier": 1, "region": "region-b", "compute": {"vm.large": 6}, "db": "db.large", "storage_gb": 500,
"tags": {"owner": "team-orders", "environment": "prod"}, "logs_to": "central", "metrics": True, "traces": False,
"backup": {"interval_h": 24, "copies_in_other_region": False, "last_restore_test_days": 400}, "dr": {"strategy": "backup-restore", "rto_h": 12}},
{"name": "payments", "account": "prod", "tier": 1, "region": "region-b", "compute": {"vm.large": 4}, "db": "db.large", "storage_gb": 200,
"tags": {"owner": "team-pay", "cost-center": "cc-12", "environment": "prod", "data-class": "pci"}, "logs_to": "central", "metrics": True, "traces": True,
"backup": {"interval_h": 0.1, "copies_in_other_region": True, "last_restore_test_days": 20}, "dr": {"strategy": "warm-standby", "rto_h": 0.5}}],
"budget_month": 2000,
}
def review(lz):
findings = []
f = lambda pillar, msg: findings.append((pillar, msg))
# landing zone and workload isolation
for a in lz["org"]["accounts"]:
if a["name"] == "management" and a["workloads"]:
f("security", "workloads in the management account")
placed = {}
for a in lz["org"]["accounts"]:
for w in a["workloads"]:
placed.setdefault(w, []).append(a["name"])
for w, accts in placed.items():
if "prod" in accts and len(accts) > 1:
f("security", f"{w} runs in production and {', '.join(x for x in accts if x != 'prod')}: one workload, one environment per account")
# IAM
idn = lz["identity"]
if not idn["root_mfa"]: f("security", "the root or owner login has no MFA")
if idn["users_with_access_keys"]: f("security", f"{idn['users_with_access_keys']} users have long-lived access keys: use SSO and short-lived roles")
for r in idn["roles"]:
if "*" in r["actions"] and "*" in r["resources"]: f("security", f"role {r['name']} allows every action on every resource")
# network
net = lz["network"]
cidrs = [("hub", net["hub"])] + list(net["spokes"].items()) + [(f"onprem {c}", c) for c in net["onprem"]]
for i, (a, ca) in enumerate(cidrs):
for b, cb in cidrs[i + 1:]:
if ipaddress.ip_network(ca).overlaps(ipaddress.ip_network(cb)):
f("reliability", f"address ranges overlap: {a} {ca} and {b} {cb}")
for s in net["subnets"]:
if "db" in s["name"] and s["public"]: f("security", f"subnet {s['name']} holds databases but is public")
for w in lz["workloads"]:
# governance
missing = REQUIRED_TAGS - set(w["tags"])
if missing: f("operational excellence", f"{w['name']} is missing tags: {', '.join(sorted(missing))}")
# observability
if not (w["logs_to"] == "central" and w["metrics"] and w["traces"]): f("operational excellence", f"{w['name']} lacks {'traces' if not w['traces'] else 'central logs or metrics'}")
# backup and DR against the tier
t = TIER[w["tier"]]
if w["backup"]["interval_h"] > t["rpo_h"]: f("reliability", f"{w['name']}: backups every {w['backup']['interval_h']} h cannot meet a tier-{w['tier']} RPO of {t['rpo_h']} h")
if not w["backup"]["copies_in_other_region"]: f("reliability", f"{w['name']}: no backup copy outside its region")
if w["backup"]["last_restore_test_days"] > 90: f("reliability", f"{w['name']}: last restore test {w['backup']['last_restore_test_days']} days ago (more than 90)")
if w["dr"]["rto_h"] > t["rto_h"]: f("reliability", f"{w['name']}: DR strategy {w['dr']['strategy']} gives RTO {w['dr']['rto_h']} h; tier {w['tier']} needs {t['rto_h']} h")
# sustainability
if CARBON[w["region"]] > 300: f("sustainability", f"{w['name']} runs in {w['region']} ({CARBON[w['region']]} gCO2e/kWh, illustrative); a lower-carbon region exists")
cost = monthly_cost(lz)
if cost > lz["budget_month"]: f("cost optimization", f"estimated USD {cost:,.0f} a month exceeds the budget of USD {lz['budget_month']:,}")
return findings, cost
def monthly_cost(lz):
total = 0.0
for w in lz["workloads"]:
total += sum(PRICE[k] * n for k, n in w["compute"].items()) + PRICE[w["db"]] + PRICE["storage.gb"] * w["storage_gb"]
if w["dr"]["strategy"] == "warm-standby":
total += 0.3 * (sum(PRICE[k] * n for k, n in w["compute"].items()) + PRICE[w["db"]])
return round(total + PRICE["nat"] * 2 + PRICE["log.gb"] * 300, 2)
def fix(lz):
lz = copy.deepcopy(lz)
for a in lz["org"]["accounts"]:
if a["name"] == "dev":
a["workloads"] = ["orders-dev", "payments-dev"]
lz["identity"].update(root_mfa=True, users_with_access_keys=0)
lz["identity"]["roles"][0] = {"name": "deployer", "actions": ["ecs:UpdateService", "ecr:GetAuthorizationToken", "ecr:BatchGetImage"], "resources": ["arn:prod:orders/*"]}
lz["network"]["spokes"]["dev"] = "10.2.0.0/16"
lz["network"]["subnets"][0]["public"] = False
o = lz["workloads"][0]
o["tags"].update({"cost-center": "cc-11", "data-class": "internal"})
o["traces"] = True
o["backup"] = {"interval_h": 0.1, "copies_in_other_region": True, "last_restore_test_days": 0}
o["dr"] = {"strategy": "warm-standby", "rto_h": 0.5}
o["compute"] = {"vm.medium": 4} # rightsized from measured CPU
for w in lz["workloads"]:
w["region"] = "region-a"
return lz
def setup():
shutil.rmtree(WORK, ignore_errors=True); os.makedirs(WORK)
json.dump(FIRST, open(p("landing-zone.json"), "w"), indent=1)
print("landing-zone.json written: 4 accounts, 2 workloads, a hub-and-spoke network; review it with verify")
def verify():
lz = json.load(open(p("landing-zone.json")))
print("== First review")
findings, cost = review(lz)
for pillar, msg in findings:
print(f" [{pillar}] {msg}")
pillars = {x for x, _ in findings}
(ok if {"security", "reliability", "operational excellence", "cost optimization", "sustainability"} <= pillars else bad)(f"{len(findings)} findings across {len(pillars)} pillars")
print(f" estimated cost: USD {cost:,.2f} a month (budget USD {lz['budget_month']:,})")
print("== Fixes applied (as a reviewed change to landing-zone.json), then review again")
fixed = fix(lz)
json.dump(fixed, open(p("landing-zone.v2.json"), "w"), indent=1)
f2, cost2 = review(fixed)
for pillar, msg in f2:
print(f" remaining [{pillar}] {msg}")
(ok if not f2 else bad)(f"the second review has {len(f2)} findings")
(ok if cost2 <= fixed["budget_month"] else bad)(f"cost after rightsizing: USD {cost2:,.2f} a month, within budget, including the warm standby")
(ok if all(TIER[w["tier"]]["rpo_h"] >= w["backup"]["interval_h"] and w["dr"]["rto_h"] <= TIER[w["tier"]]["rto_h"] for w in fixed["workloads"]) else bad)("every tier-1 workload meets its RTO and RPO")
(ok if not any(ipaddress.ip_network(a).overlaps(ipaddress.ip_network(b)) for a, b in [(fixed["network"]["spokes"]["dev"], fixed["network"]["spokes"]["prod"]), (fixed["network"]["spokes"]["dev"], fixed["network"]["hub"])]) else bad)("no address ranges overlap")
print("\nRESULT:", "all checks passed" if not FAILS else f"{len(FAILS)} check(s) failed")
sys.exit(1 if FAILS else 0)
def reset():
shutil.rmtree(WORK, ignore_errors=True); print(f"capstone 10 reset: {WORK} removed")
if __name__ == "__main__":
{"setup": setup, "verify": verify, "reset": reset}.get(sys.argv[1] if len(sys.argv) > 1 else "", lambda: sys.exit(__doc__))()| Symptom | Cause | Fix |
|---|---|---|
| You want to see a finding again | verify fixes the design. | Reset, run setup, and read landing-zone.json before verify. |
| Your provider's prices differ | The estimate uses example unit prices in review.py. | Replace them with your provider's current prices; the review logic stays the same. |
Every check prints PASS or FAIL with a reason, and the scripts keep their logs in the work folder under ~/labs/capstones; read them before running again.
python3 10-cloud-architecture/review.py reset
It removes: ~/labs/capstones/cloud (landing-zone.json and the review). Downloaded container images that are not named cap- stay in Docker's cache; remove them with docker image rm if you need the space.
| Provider | Equivalent |
|---|---|
| AWS | AWS Organizations and Control Tower, IAM Identity Center, Transit Gateway, AWS Backup, and Budgets. |
| Azure | Management groups with Azure landing zones, Entra ID, Virtual WAN or a hub VNet, Azure Backup, and Cost Management budgets. |
| Google Cloud | Resource hierarchy with folders, Cloud Identity, Shared VPC or Network Connectivity Center, Backup and DR, and budgets. |
verify proves the build works. The rubric is for you, or a reviewer, to judge how well: aim for every row in Meets, then pick rows to take to Exceeds.
| Criterion | Meets | Exceeds |
|---|---|---|
| Security | No long-lived keys, no public workloads, least privilege. | Guardrails prevent the mistakes, not just find them. |
| Reliability | The design meets its RPO and RTO on paper. | You have a restore test plan that proves it. |
| Cost | The estimate is under budget. | You know the top three cost drivers and their alternatives. |
| Review | Every finding has a pillar and a fix. | Your fixes are recorded as architecture decision records. |
Then test what you know with the assessments.