Lesson 19 · 27 min read

Cost Review and Final Production Architecture

Where the money goes, how to cut it, and the complete architecture you have built — box by box.

What you'll learn in this lesson

  1. Concept: the bill is a design document
  2. The five ways AWS charges you
  3. What the final architecture costs
  4. The cost levers, ranked by payoff
  5. Data transfer: the most overlooked cost
  6. Savings Plans and Reserved Instances
  7. Seeing the bill: tags, Cost Explorer, budgets, anomalies
  8. Unit economics: what does one customer cost?
  9. The orphan sweep: finding what you forgot
  10. The final architecture, box by box
  11. Go-live readiness checklist
  12. Honest verdict: AWS or a platform?
  13. Where to go next
  14. The whole course in twenty sentences
  15. Interview corner
  16. Capstone task
  17. Tear it all down safely
  18. Conclusion

Concept

You have built a complete production system. This last lesson does two things that every engineer does at the end of a build: count the cost and review the whole design. They are one job. In the cloud, the bill is a description of your design, line by line. Every hour a server runs, every gigabyte of logs and every idle IP address appears on it.

Words used in this lesson
  • On-demand pricing is the normal price you pay per hour or per second, with no promise to keep using the service.
  • EC2 is the AWS service that rents you virtual servers. Each server is called an instance. EBS is the network disk attached to an instance.
  • RDS is the AWS service that runs a database (here PostgreSQL) for you. ElastiCache is the AWS service that runs a fast in-memory cache (here Valkey, a Redis-compatible store).
  • S3 is the AWS service that stores files (called objects) in buckets. CloudFront is a CDN: a network of servers around the world that keeps copies of your files close to users.
  • ALB (Application Load Balancer) is a service that receives web traffic and spreads it over several servers. An Availability Zone (AZ) is one separate data centre inside an AWS Region.
  • NAT Gateway is a managed box that lets servers in a private subnet reach the internet, but does not let the internet reach them.
  • Egress means data leaving AWS. Data transfer means data moving between places, and AWS charges for most of it.
  • Right-sizing means choosing the smallest server size that still does the job well.
  • Graviton is a family of ARM-based processors that AWS designs. They give the same work for a lower price than the usual x86 (Intel or AMD) processors.
  • Spot Instances are spare EC2 servers sold at a big discount. AWS can take them back with a short warning.
  • Terraform is a tool that creates cloud resources from code files. CI (continuous integration) is a system that builds and tests your code automatically on every change.
The analogy — a utility bill for a building you designed

An electricity bill tells you which appliances you left on. The AWS bill does the same for infrastructure: a forgotten load balancer, a chatty log group, a NAT gateway humming all month. Reading it monthly, with the diagram beside it, is how you keep the building efficient after it is built.

Do not treat cost as something to fix in a hurry at the end. Treat it as a property of the design, like latency. Measure it, set a budget for it and review it.

The five ways AWS charges you

Almost every line on the invoice follows one of five patterns. If you know the pattern, you can guess the cost of a service you have never used:

PatternHow it is measuredExamplesThe trap
Compute timePer second while an instance runsEC2, RDS, ElastiCache, ALB hours, NAT hoursStopped ≠ free for RDS and cache; idle ≠ free for anything
StoragePer GB per month, whether used or notEBS, RDS, S3, snapshots, ECR, log groupsIt bills until you delete it, even if nothing reads it
Requests / usage unitsPer operation or per capacity unitS3 requests, ALB LCUs, CloudFront requests, LambdaCheap per unit, huge at scale
Data transferPer GB leaving AWS or crossing zones/regionsInternet egress, cross-AZ, NAT processingInbound is free; the rest adds up quietly
Addresses and endpointsPer hour just for existingPublic IPv4, Elastic IPs, NAT gateways, interface endpointsTiny individually, unnoticed in bulk

The main idea: AWS bills for existing, not for using. A server with zero visitors costs the same as a busy one. This is the big difference from the per-request pricing of Lesson 0. It is also why forgotten resources are the biggest source of waste.

What the final architecture costs

Here is an honest total for three sizes of the same design. The prices are for the Mumbai Region, on-demand, running 24 hours a day. They are estimates for planning, not quotes. Prices change and traffic varies. The AWS Pricing Calculator (a free AWS web tool where you enter your resources and get a monthly price) gives a more exact number for any line.

LineStarter
one server
Production
this course
Resilient
scaled + HA
Compute (EC2)1 × t3.micro ≈ $82 × t3.small ≈ $323 × t3.medium ≈ $96
Disks (EBS)≈ $2≈ $4≈ $6
Load balancernoneALB ≈ $20ALB ≈ $30
Public IPv4 addresses1 ≈ $4≈ 4 ≈ $14≈ 5 ≈ $18
Database (RDS)t4g.micro, single-AZ ≈ $16t4g.micro, single-AZ ≈ $16t4g.small Multi-AZ ≈ $58
Cache (ElastiCache)nonet4g.micro ≈ $122 × t4g.small ≈ $45
NAT Gatewaynonenone≈ $40 + data
S3 + CloudFront≈ $1≈ $3≈ $15
Route 53≈ $1≈ $1.50≈ $3
Logs, alarms, dashboard≈ $2≈ $8≈ $25
Security (GuardDuty, WAF, secrets)≈ $0–5≈ $15≈ $40
Backups and snapshots≈ $1≈ $3≈ $15
Approx. total / month≈ $35 (₹3,000)≈ $130 (₹11,000)≈ $390 (₹33,000)
  • Compare with Lesson 0. It said “$15 to $25” for one small server plus one small database. That counted only the server and the database. The Starter column also adds the disk, the IP address, logging and backups that a real deployment needs. It is still small. The build now happens in CI (Lesson 14), so a t3.micro server is enough to run the app.
  • The big step is the load balancer tier. Going from Starter to Production roughly triples the bill. Servers are not the reason. Each new part (load balancer, second server, cache, security services) has a fixed monthly charge. This is the moment to ask honestly whether you need it yet (the warning from Lesson 12).
  • Costs that depend on usage stay small at this scale. Requests, CDN traffic and log volume matter much more once you have thousands of daily users.
  • Compare with the alternative. A platform (Vercel Pro, Railway, Render) often costs $20–100 a month for a project of this size once you add a database. That price also includes the operations work. So do not compare AWS line items with platform line items only. Compare the AWS line items plus your time (see the honest verdict below).

The cost levers, ranked by payoff

A cost lever is one change that lowers the bill. Work down this list in order. The top items have no risk. The bottom ones need care. Most bills drop 30–50% after the first five.

#LeverHowTypical saving
1Delete what you are not usingUnattached disks, old snapshots, idle load balancers, forgotten dev environments, unused Elastic IPsOften 10–30% of a neglected bill; zero risk
2Right-sizeLook at CPU and memory over two weeks. A server at 8% CPU can move down one size. Compute Optimizer (free) gives advice20–50% of compute
3Move to Graviton (ARM)Use t4g / m7g / db.t4g / cache.t4g instead of x86 types. Multi-arch Docker builds (one image that runs on both ARM and x86) make it a small changeAbout 20% cheaper for similar performance
4Commit to the steady baselineCompute Savings Plan (servers) or 1-year Reserved Instances / Database Savings Plan (database) for what never goes away30–60% off on-demand
5Turn off non-productionSet the dev/staging Auto Scaling group to 0 and stop RDS outside work hours; or destroy and re-create with Terraform60–70% of those environments
6Kill the NAT GatewayPut app servers in public subnets, use the free S3/DynamoDB gateway endpoints, and add only the interface endpoints you need$40+/month per NAT
7Set log retention and log levels30-day retention, info level, no health-check logging; export old logs to S3Frequently the largest surprise on the bill
8Tier and expire in S3Lifecycle rules (automatic move or delete after N days), Intelligent-Tiering, abort incomplete uploads, expire old versionsUp to 40–70% of storage cost
9Serve static content from the edgeCloudFront in front of assets and cacheable pages: origin bandwidth and load dropCuts egress and server count
10Use Spot for interruptible workBackground workers and batch jobs that can safely stop and restart (never the main database)Up to about 90% off (often 60–70% in practice)
Do not save money by removing safety

The wrong cuts save a little money every month but risk a large loss on a bad day. Examples are turning off backups, running production on a single server, switching off encryption or logging, and skipping the restore drill. Cut waste, not resilience. When in doubt, ask: “what would this cost us on the day it fails?”

Right-sizing with evidence

Right-sizing means moving each server to the smallest size that still copes. Compute Optimizer is a free AWS service that does this analysis for you. You opt in, and it needs at least 30 hours of CloudWatch metrics from the last 14 days. Then it marks each instance as over-provisioned (too big), optimized (about right) or under-provisioned (too small), and suggests a size. You can also check by hand: look at two weeks of daily average and maximum CPU for the Auto Scaling group in CloudWatch. An average of 8% and a maximum of 30% means a smaller size is safe.

Watch memory as well as CPU (you get memory numbers from the agent in Lesson 17). CPU alone can mislead you. An app that needs a lot of memory but little CPU should move to a type with a better memory-to-CPU ratio, not to a smaller one.

Data transfer: the most overlooked cost

PathApprox. priceDesign consequence
Internet → AWS (inbound)FreeUploads cost nothing to receive
AWS → internet, from EC2/ALBFirst 100 GB/month free, then about $0.109/GBServe big files from S3 + CloudFront instead
S3 → CloudFrontFreeThe CDN is often cheaper than serving the bytes yourself
CloudFront → internetFirst 1 TB/month free, then ~$0.11/GB (India)Cache aggressively
Between Availability Zones~$0.01/GB each directionChatty cross-AZ traffic (app ↔ DB in another AZ) is a hidden tax
Through a NAT Gateway~$0.056/GB on top of the hourly chargeSend S3 traffic through a free gateway endpoint
Same AZ, private IPsFreeTalk over private addresses, not public ones
Between regions~$0.02+/GBCross-region replication and copies are not free

You cannot avoid all of these costs, but you can see them. In Cost Explorer (the AWS tool that charts your spending), filter by a usage type that contains DataTransferto find the cause.

Savings Plans and Reserved Instances

On-demand pricing is the highest price. You pay it because you promise nothing. If you know a resource will run for a year anyway, you can promise that and get a discount. A Savings Plan is a promise to spend a fixed amount per hour for 1 or 3 years. A Reserved Instance (RI) is a promise to run one specific instance type for 1 or 3 years. In both cases AWS gives you a lower price in return:

Compute Savings PlanReserved Instance (RI)
You commit toA dollar amount per hour of compute for 1 or 3 yearsA specific instance type/engine/region for 1 or 3 years
FlexibilityApplies across instance families, sizes, regions, even Fargate and LambdaTied to what you reserved (Convertible RIs bend a little)
CoversEC2, Fargate, LambdaEC2, plus RDS and ElastiCache. (Compute Savings Plans do not cover databases. A separate Database Savings Plan, 1 year only, now exists with smaller discounts, up to about 20% for provisioned RDS and ElastiCache Valkey.)
DiscountUp to 66% vs on-demandUp to about 70%; commonly 30–60%
PaymentNo upfront / partial / all upfront (more upfront = bigger discount)Same options
A safe way to commit

Wait until the workload has run steadily for two to three months. Commit only to the baseline you are sure to keep (for example, the two servers that never go away). Leave the spikes on-demand. Start with 1 year and no upfront payment, and write down the expiry date. The common mistake is to commit to capacity that you shrink later. You still owe that money.

Seeing the bill: tags, Cost Explorer, budgets, anomalies

You cannot manage a cost if you cannot tell what caused it. Four tools help, in order of value:

  1. Tag everything — Terraform did most of it already

    A tag is a label (a key and a value) that you attach to a resource. The default_tags block from Lesson 15 already puts Project, Environment and ManagedBy on every resource. One more step makes them useful: activate them as cost allocation tags in Billing → Cost allocation tags. They show up in reports about a day later, and only for costs after you activate them. Then the bill splits by project and environment.

  2. Cost Explorer — read it weekly at first

    Cost Explorer is the AWS tool that charts your spending over time. Group by Service first. Then open the biggest one and group by Usage type. Switch to daily view to find the day the cost jumped. Then match that day to a deploy or a change.

  3. Budgets — the smoke detector

    A budget is a limit you set for your spending. AWS sends an alert when you get near it. Lesson 5 set one budget for the whole account. Now make one for the project, with alerts at 50%, 80% and 100% of actual spending and at 100% of forecast. The forecast alert fires early, when AWS predicts that you will go over the limit, not after you have.

    Billing → Budgets → Create: monthly cost budget for myapp, with email alerts to the team address at 80% of actual and 100% of forecast.

  4. Cost Anomaly Detection — the tripwire

    Cost Anomaly Detection is a free AWS feature that learns your normal spending for each service and alerts you when it sees something unusual. Examples are a runaway log group, or a crypto-miner running in a Region you never use. Create a monitor for all services in Billing → Cost Anomaly Detection. Send the alert to the same SNS topic (a messaging channel that can email you) as your operational alarms. It would have caught most of the costly mistakes described in Lesson 5 within a day.

Unit economics: what does one customer cost?

A multi-tenant SaaS is one software service (SaaS means software sold as a service) that many customers, called tenants, share. For this kind of product, the total bill is not the most useful number. The useful number is cost per tenant, because you compare it with what each tenant pays you. This is called unit economics: the cost and income of one unit, here one customer.

a back-of-envelope model
Monthly infrastructure (Production column)        ≈ $130
Active tenants                                    40
Fixed cost per tenant                             130 / 40 = $3.25

Add per-tenant variable costs:
  S3 storage (avg 2 GB × $0.025)                  $0.05
  Data out via CloudFront (avg 5 GB × $0.11)      $0.55      (after free tier)
  Email, SMS, third-party APIs                    $0.40
  Support and your time are NOT here yet.

≈ $4.25 per tenant per month.   Price of a plan: $29   →   ~85% gross margin on infrastructure

The exact numbers do not matter. What matters is that you can now answer two questions. The first is “what happens when we have 400 tenants?” The fixed part barely moves, while storage and transfer grow. The second is “which customers lose us money?” One example is a customer who stores 500 GB of video on a $29 plan. Use tenant names in S3 key prefixes and tenant IDs in logs (Lessons 11 and 17) to measure real storage and traffic for each tenant. Then set plan limits that protect your margin. (Gross margin is the share of the price left after the direct costs.)

The orphan sweep: finding what you forgot

An orphan is a resource that nothing uses any more but that still bills you. Everything you create keeps billing until you delete it. A sweep every three months pays for itself. Check these:

Look forWhereWhy it bills
Unattached EBS volumesEC2 → Volumes, state availableDisks left behind by terminated servers. Snapshot if unsure, then delete
Unattached Elastic IPsEC2 → Elastic IPs, no instanceStill billed as public IPv4
Old EBS and manual RDS snapshotsEC2 → Snapshots; RDS → Snapshots → ManualKept forever until deleted, including the drill copies
A forgotten NAT GatewayVPC → NAT gateways~$40 a month each
Idle load balancersEC2 → Load balancers, no requestsHourly charge whether used or not
Log groups that never expireCloudWatch → Log groups, retention Never expireStorage grows every month
Instances in other regionsEC2 → EC2 Global ViewThe one you forgot in Virginia. Also the first check after a suspected compromise

The final architecture, box by box

Here is everything the series built, in one place. First you see the path a user's request takes. Then you see the network it runs in. Then you see the path a code change takes to get there.

  1. User's browser
    types https://yourapp.com
  2. DNS: name → IP (Lesson 3, 13)
    Route 53
    answers with the CloudFront or ALB address
  3. static file? served from the edge (Lesson 11)
    CloudFront (CDN)
    cache near the user; passes dynamic requests on
  4. TLS ends here or at the ALB (Lesson 4)
    ALB (load balancer)
    picks a healthy server; Auto Scaling adds more under load
  5. inside your VPC, public subnet (Lesson 6, 12)
    EC2 · Nginx
    receptionist on :80/:443 — forwards to the app on :3000
  6. 127.0.0.1:3000 (Lesson 7, 10)
    EC2 · PM2 → Next.js / Node
    your code, kept alive and restarted on crash
  7. private subnet only (Lesson 8, 16)
    RDS (PostgreSQL) · Redis · S3
    data, cache/sessions, files — never reachable from the internet
The whole production setup, in the order one request meets each piece. Lessons 0–4 covered the arrows at the top; this reading explains every box below them. · the map
Internet → Internet Gateway
VPC · 10.0.0.0/16 · ap-south-1
Public subnet · 10.0.1.0/24
route table: 0.0.0.0/0 → Internet Gateway
ALB — public IP
EC2 · Nginx + app — SG: 22 from you, 80/443 from ALB
Private subnet · 10.0.2.0/24
route table: no internet route (NAT only for updates)
RDS PostgreSQL :5432 — SG: only from the app's SG
Redis :6379 — SG: only from the app's SG
One VPC, two kinds of subnet. Public subnets have a route to the Internet Gateway; private subnets do not, so the database can only be reached from inside. · 10.0.0.0/16
  1. Your laptop
    git push origin main
  2. GitHub receives the commit
    GitHub Actions (CI)
    installs, lints, runs tests, npm run build
  3. any step fails → stop here, nothing deployed
    Docker build
    packages app + Node + deps into one image, pushed to a registry
  4. same image runs on your laptop and on EC2
    Deploy (CD)
    EC2 pulls the image · or Terraform/ASG rolls new servers
  5. health check passes → old version retired
    PM2 / container restarted
    zero-downtime reload
  6. Nginx keeps serving throughout
    Users
    see the new version — minutes after the push, no SSH
From git push to live: the automated pipeline Lessons 9, 14 and 15 build. Lesson 7 does the same thing by hand first, so you understand every step the automation later performs.

Here is the same system as a table. It shows what each piece does, what breaks when it fails (the question that shows whether you really understand it) and what it costs:

PieceLessonJobIf it fails…Cost
Route 5313Turns yourapp.com into the ALB / CDN address; health checks; private namesNobody can find the site (multi-provider is the fix at scale)~$1–3
CloudFront + S311Caches static files at the edge; stores uploads and assets privatelyImages and assets slow or missing; app still works~$3–15
ALB + ACM12, 4Terminates HTTPS, spreads traffic, health-checks targetsSite unreachable; AWS runs it across 2 AZs~$20–30
Auto Scaling group + EC27, 9, 12Stateless app servers running the Docker image, replaced not repairedOne server dies → the ALB routes around it; ASG replaces it~$32–96
VPC, subnets, SGs6The private building: public floor for the ALB and servers, private floor for dataMisconfiguration exposes data (the biggest risk)Free
RDS PostgreSQL8The system of record: relational data with backups and point-in-time restoreApp errors; restore or fail over. The one thing you cannot lose~$16–58
ElastiCache (Valkey)16Cache, sessions, rate limitsSlower, users may need to log in again; app should fail open~$12–45
IAM roles + OIDC5, 14Every machine and pipeline has short-lived, scoped credentialsAccess denied errors; or, if too broad, a bigger breachFree
ECR + GitHub Actions9, 14Builds, tests, ships immutable images; rollbacks by tagCannot deploy; running site unaffected~$1 + free tier
Terraform + S3 state15The whole estate as reviewed codeCannot change infra; running site unaffectedPennies
CloudWatch + SNS17Metrics, logs, dashboards and alerts that reach a humanYou are blind, and nobody is told~$8
CloudTrail, GuardDuty, backups18Detection, audit and recoveryBreaches go unseen; disasters are unrecoverable~$15–20

Single points of failure left in this design

A single point of failure is one part that, if it breaks, stops the whole system. An honest review lists them, so you can decide what to spend money on next:

  • The database is single-AZ. It runs in one Availability Zone only. If that zone fails, you must restore from a backup, and that takes time. Fix: Multi-AZ, which keeps a standby copy in a second zone (it doubles the RDS line).
  • One Region. If a whole Region fails, you are down. Fix: keep backup copies in another Region (advised earlier) so you can recover. Active-active (running live in two Regions at the same time) is a large, costly step that most products never need.
  • One AWS account. Production, staging and backups share one blast radius (the amount of damage one mistake or breach can cause). Fix: AWS Organizations, a service that manages many separate accounts together. This is the usual next step.
  • One cache node (sessions are lost if it fails). Fix: add a replica, a second copy that takes over automatically.
  • One person who understands it. Fix: use the runbooks (step-by-step guides for incidents), the Terraform repository and the drills you wrote. Also train a second person who has really run them.

Go-live readiness checklist

Before a real launch, go through this table with another person. Each row turns a whole lesson into one question:

AreaReady means
ReliabilityAt least 2 servers in 2 AZs; health checks tested by killing a server; RDS backups on and a restore practised; rollback rehearsed
SecurityLesson 18 checklist complete; nothing but the ALB public; no keys anywhere; MFA everywhere; secrets in SSM/Secrets Manager
PerformanceLoad tested at 2× expected peak; p95 known; DB connection budget computed at max scale; static assets on the CDN
ObservabilityAlarms on the four golden signals (latency, traffic, errors, saturation) tested; logs structured; dashboard exists; someone is on the alert address; runbooks linked
OperationsEverything in Terraform; deploys via the pipeline with an approval; a documented way to reach a server (SSM)
CostBudget alerts set; tags active; log retention set; no NAT unless justified; monthly review scheduled
PeopleAt least two people can deploy, roll back and restore; one runbook for “the site is down”; escalation path written

Honest verdict: AWS or a platform?

After nineteen lessons, you can say something a beginner cannot: most projects should not run on raw AWS. A platform (a service such as Vercel, Railway or Render that runs your app for you) does the work of Lessons 6–18 when you run git push. Now you know exactly what it does for you and what control you give up. Compare them with real numbers:

Platform (Vercel / Railway / Render)Your own AWS setup
Monthly bill, small scaleOften lower or equal~$35–130 in this design
Bill as traffic growsGrows with usage; can spikeMostly fixed steps; cheaper per user at scale
Your time to operateNear zeroReal: patches, incidents, on-call, cost reviews. Budget several hours a month, and more when things break
Long jobs, workers, websockets, big uploadsLimited or awkwardNo limits
Database and network controlLimitedComplete
Compliance, data residency, private networkingDepends on the planFull control
Blast radius of your own mistakesSmallLarge: you can delete production
A useful rule

An engineer's time is your most expensive resource. If running AWS takes ten hours a month, that time costs more than the whole infrastructure bill. Move to your own AWS only when a real need is bigger than that time cost. Real needs are workload limits, cost at scale, compliance rules or control. Many teams choose a mix: the front end on a platform, and the heavy backend and data on AWS. See Hosting Platforms Explained for the full decision guide.

This knowledge is still useful if you stay on a platform. You can find problems that it hides, read its bill, judge its limits and leave when you must. That was the goal from Lesson 0.

Where to go next

You now have the foundations. Here are sensible next steps, by direction:

DirectionWhat to learnWhy
Fewer servers to runECS on Fargate, App Runner, LambdaRun your containers without managing servers yourself. This is the natural next step after Lesson 9
Bigger orchestrationKubernetes (EKS)Kubernetes is a system that runs and manages many containers across many servers. Use it when you have many services and teams. Expect real operating work
Better infra codeTerraform modules and testing, AWS CDK, PulumiReuse code and stay safe at scale (AWS CDK and Pulumi let you write infrastructure in a normal programming language)
Multi-accountAWS Organizations, Control Tower, SCPs, IAM Identity Center for allKeep environments apart and limit the damage of one mistake (SCPs are rules that cap what every account may do)
Deeper dataAurora, read replicas, DynamoDB, OpenSearch, data pipelinesFor when one Postgres instance is no longer enough
Better operationsOpenTelemetry, SLOs, incident response, chaos testingTreat reliability as a skill of its own (SLO = a target for how reliable the service must be; chaos testing = breaking things on purpose to learn)
FinOpsCost allocation, showback (showing each team its own costs), commitment strategyTreat cost as an engineering practice (FinOps = managing cloud money well)
CredentialsAWS Solutions Architect Associate, then Professional or DevOps EngineerA structured path through the rest of the platform

If you are early in your career: do the series again from an empty account, using only Terraform, and destroy everything at the end. Doing it twice turns understanding into skill. If you have several years of experience: focus on the judgement this series tried to teach. That means what not to build, where things can fail, how to measure, and how to say “not yet” to a new component. This judgement, not the console clicks, is what seniority looks like.

The whole course in twenty sentences

LessonThe sentence to remember
Lesson 0AWS gives you raw building blocks; Vercel gave you a finished house — the price of control is responsibility.
Lesson 1Every server is Linux: learn the shell, permissions, users and processes, or nothing else is debuggable.
Lesson 2A request is IP → port → firewall → app; “timed out” means blocked, “refused” means nothing is listening.
Lesson 3DNS is a cached phone book; TTL is your rollback speed.
Lesson 4HTTPS is a certificate chain of trust; let Let’s Encrypt and ACM do the renewing.
Lesson 5IAM is deny-by-default; machines wear roles, humans use MFA, nobody holds long-lived keys.
Lesson 6A subnet is public only because of one route-table row; data lives where no route reaches.
Lesson 7A server is a rented Linux box; the manual deploy is the blueprint for every automation.
Lesson 8Managed Postgres moves patching and backups to AWS, never your schema, queries or restores.
Lesson 9A container is the whole box shipped once: build small, tag by SHA, keep secrets out.
Lesson 10Nginx is the receptionist: TLS, compression, limits — and your app stays private.
Lesson 11Files live in S3 and reach users through a CDN; version file names, do not invalidate.
Lesson 12Scale by making servers stateless, cloning them behind an ALB, and testing by breaking them.
Lesson 13Route 53 aliases make the bare domain point at AWS; weighted DNS is the safest migration.
Lesson 14A pipeline is your manual deploy written down, with tests as a gate and OIDC as the key.
Lesson 15Terraform is the blueprint: read every plan, guard the state, protect stateful resources.
Lesson 16Redis is a shared whiteboard, never the only copy — cache with TTLs, fail open.
Lesson 17Alert on symptoms with runbooks; logs are structured, tenant-tagged and never hold secrets.
Lesson 18Assume breach: layers, least privilege, detection, and a backup you have actually restored.
Lesson 19Cost is a design constraint you review monthly, per customer, like uptime.

Interview corner

These last questions are open questions about a whole system. Senior interviews are often built around them. Answer aloud, in a clear order, before you open the answer.

Design the AWS architecture for a multi-tenant SaaS expecting 1,000 concurrent users. Walk me through it.

Edge: Route 53 (a wildcard alias sends every tenant subdomain, like acme.yourapp.com, to the same place) → CloudFront for assets and cacheable content, TLS via ACM.

Compute: ALB across two AZs → Auto Scaling group of stateless containerised app servers (at least 2 servers; target tracking adds or removes servers to keep CPU or requests per server near a target), rolled with instance refresh from a CI/CD pipeline using OIDC.

Data: RDS PostgreSQL in private subnets (Multi-AZ when revenue justifies it), tenant isolation in queries or with RLS (row-level security, a PostgreSQL feature that hides other tenants' rows); S3 with tenant-prefixed keys and presigned uploads; ElastiCache for sessions, cache and rate limits.

Operate: Terraform, CloudWatch alarms on golden signals, structured tenant-tagged logs, backups with a tested restore, GuardDuty/CloudTrail, least-privilege IAM. Work out the size by turning users into requests per second, then load test it; check DB connections at max scale.

Trade-offs to name: the extra cost of the load balancer tier compared with a single server at the start, the risk of one Region, and the work of running it yourself compared with a platform.

Your AWS bill doubled this month. How do you investigate?

Cost Explorer grouped by service, then usage type, at daily granularity to find the day it changed; compare with deploys and changes. Common culprits: NAT or data-transfer charges, log ingestion, a new instance or load balancer, a forgotten environment, an unexpected region (check all Regions). Use cost allocation tags to attribute it, Cost Anomaly Detection to confirm, fix the cause, and add a budget or anomaly alert so it is caught sooner next time.

How would you cut this system's cost by 30% without hurting reliability?

Remove waste first (orphans, non-prod off-hours, log retention), right-size using two weeks of metrics, move to Graviton, buy a Savings Plan and RDS/ElastiCache reservations for the steady baseline, add S3 lifecycle rules, eliminate the NAT Gateway with endpoints, and improve CDN caching. Do not touch backups, multi-AZ or monitoring.

What is your strategy if the whole region fails?

Decide the RTO and RPO first. (RTO is how long you can be down. RPO is how much recent data you can lose.) Baseline: infrastructure in Terraform so it can be recreated in another region, cross-region copies of RDS snapshots and S3 replication, DNS control in Route 53, and a rehearsed runbook. Warm standby (a small copy always running in a second Region) or active-active makes recovery faster. It costs much more and makes keeping data consistent harder. Choose by business need.

A new engineer joins. What do they need to safely ship on day one?

SSO access with MFA and least-privilege groups (no keys), the repository with the pipeline and Terraform, branch protection with required checks, a staging environment that mirrors production, the runbooks and dashboard, and a buddy for their first deploy and rollback drill.

When would you recommend NOT using AWS directly for a project?

When the team is small, traffic is modest, requirements fit a platform (frontend plus quick API, standard database), and operating infrastructure would consume more engineer time than it saves in cost or unlocks in capability. Revisit when concrete limits — long jobs, compliance, cost at scale, network control — appear.


Capstone task

The final exercise is the whole course in one go. Do it in your own AWS account, with a budget alert set, and keep notes — they become your portfolio piece.

  1. Draw the architecture from memory on paper, labelling each box with its lesson number and Security Group rules. Compare with the figures above; fix the gaps.
  2. Rebuild it from Terraform in a fresh region (or a new account). Time it. Note everything that needed a manual step and bring it into code.
  3. Deploy an app through the pipeline, then break it with a bad release and recover with the rollback workflow. Record the time to recover.
  4. Run a game day (a planned practice session where you break things on purpose): kill a server under load, stop Redis, fill a disk, revoke a key. For each one, write down which alarm fired (or failed to) and how long it took to notice.
  5. Do the restore drill and write down the RTO and RPO you measured.
  6. Price it with the AWS Pricing Calculator, compare with your actual first-week bill in Cost Explorer, and explain any difference over 10%.
  7. Write the README a new teammate would need: architecture diagram, how to deploy, roll back, get a shell, restore, and who to call. Ask someone to follow it cold.
  8. Tear it down (next section) and confirm the bill returns to zero.

Tear it all down safely

When you finish practising, remove everything so that nothing bills while you are not looking. Follow this order:

  1. Export anything you want to keep

    Keep your notes, the Terraform code (in Git) and any snapshot you still want. After you delete something, it is gone.

  2. Destroy what Terraform created

    Infrastructure
    • cd infra && terraform plan -destroy -var-file=prod.tfvars

      Read the list of what will be deleted — this is the plan you most want to read

    • terraform destroy -var-file=prod.tfvars

      Remove prevent_destroy and deletion_protection on the database first if this really is a practice account (Lesson 15)

  3. Delete what you made by hand

    • S3 buckets: empty them including old versions, then delete them. Delete the CloudTrail and Terraform state buckets last.
    • ECR repositories and their images; CloudWatch log groups.
    • RDS manual snapshots, EBS snapshots and cross-region copies.
    • The Route 53 hosted zone (it bills $0.50 a month while it exists) and any domain you no longer want (a domain renews by itself unless you turn that off).
    • IAM roles, policies, users, the OIDC provider and access keys created for the exercise.
    • GuardDuty detector, AWS Config recorder, CloudFront distributions (disable first, then delete).
  4. Run the orphan sweep in every region, and check the bill tomorrow

    Use the orphan sweep table above. Then look at Cost Explorer the next day and again after a week. Keep the billing alert from Lesson 5 for good. It is free, and it warns you on the day you forget something.

Conclusion

You started this series knowing how to git push. Now you can design, build, secure, watch, price and rebuild a production system. More importantly, you can explain why every piece is there and what happens when it breaks.

  • AWS bills for existing, not for using: compute, storage, requests, transfer and addresses. Read the bill like a diagram.
  • Cost levers in order: delete waste, right-size, Graviton, commit to the baseline, turn off non-prod, remove NAT, control logs, tier storage, use the CDN.
  • Make it visible: tags, Cost Explorer, budgets with forecast alerts, anomaly detection, and cost per tenant.
  • Know your design's weak points — single-AZ database, single region, single account, single person — and spend deliberately on the ones that matter.
  • Choose the platform on evidence, including the value of your own time.

Servers, networks, databases and pipelines are only tools. The lasting skill is the way of thinking behind them. Understand the layer below you. Automate what you have done by hand. Expect things to fail. Measure before you decide. Go and build something, destroy it, and build it again.


End of Lesson 19 — and the end of DevOps, From Zero. Return to the series index or the glossary any time.

Published by Jainik · Last updated · How these lessons are made

Keep learning

Part of the study guide

Related series