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
- Concept: the bill is a design document
- The five ways AWS charges you
- What the final architecture costs
- The cost levers, ranked by payoff
- Data transfer: the most overlooked cost
- Savings Plans and Reserved Instances
- Seeing the bill: tags, Cost Explorer, budgets, anomalies
- Unit economics: what does one customer cost?
- The orphan sweep: finding what you forgot
- The final architecture, box by box
- Go-live readiness checklist
- Honest verdict: AWS or a platform?
- Where to go next
- The whole course in twenty sentences
- Interview corner
- Capstone task
- Tear it all down safely
- 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.
- 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.
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:
| Pattern | How it is measured | Examples | The trap |
|---|---|---|---|
| Compute time | Per second while an instance runs | EC2, RDS, ElastiCache, ALB hours, NAT hours | Stopped ≠ free for RDS and cache; idle ≠ free for anything |
| Storage | Per GB per month, whether used or not | EBS, RDS, S3, snapshots, ECR, log groups | It bills until you delete it, even if nothing reads it |
| Requests / usage units | Per operation or per capacity unit | S3 requests, ALB LCUs, CloudFront requests, Lambda | Cheap per unit, huge at scale |
| Data transfer | Per GB leaving AWS or crossing zones/regions | Internet egress, cross-AZ, NAT processing | Inbound is free; the rest adds up quietly |
| Addresses and endpoints | Per hour just for existing | Public IPv4, Elastic IPs, NAT gateways, interface endpoints | Tiny 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.
| Line | Starter one server | Production this course | Resilient scaled + HA |
|---|---|---|---|
| Compute (EC2) | 1 × t3.micro ≈ $8 | 2 × t3.small ≈ $32 | 3 × t3.medium ≈ $96 |
| Disks (EBS) | ≈ $2 | ≈ $4 | ≈ $6 |
| Load balancer | none | ALB ≈ $20 | ALB ≈ $30 |
| Public IPv4 addresses | 1 ≈ $4 | ≈ 4 ≈ $14 | ≈ 5 ≈ $18 |
| Database (RDS) | t4g.micro, single-AZ ≈ $16 | t4g.micro, single-AZ ≈ $16 | t4g.small Multi-AZ ≈ $58 |
| Cache (ElastiCache) | none | t4g.micro ≈ $12 | 2 × t4g.small ≈ $45 |
| NAT Gateway | none | none | ≈ $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.
| # | Lever | How | Typical saving |
|---|---|---|---|
| 1 | Delete what you are not using | Unattached disks, old snapshots, idle load balancers, forgotten dev environments, unused Elastic IPs | Often 10–30% of a neglected bill; zero risk |
| 2 | Right-size | Look at CPU and memory over two weeks. A server at 8% CPU can move down one size. Compute Optimizer (free) gives advice | 20–50% of compute |
| 3 | Move 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 change | About 20% cheaper for similar performance |
| 4 | Commit to the steady baseline | Compute Savings Plan (servers) or 1-year Reserved Instances / Database Savings Plan (database) for what never goes away | 30–60% off on-demand |
| 5 | Turn off non-production | Set the dev/staging Auto Scaling group to 0 and stop RDS outside work hours; or destroy and re-create with Terraform | 60–70% of those environments |
| 6 | Kill the NAT Gateway | Put app servers in public subnets, use the free S3/DynamoDB gateway endpoints, and add only the interface endpoints you need | $40+/month per NAT |
| 7 | Set log retention and log levels | 30-day retention, info level, no health-check logging; export old logs to S3 | Frequently the largest surprise on the bill |
| 8 | Tier and expire in S3 | Lifecycle rules (automatic move or delete after N days), Intelligent-Tiering, abort incomplete uploads, expire old versions | Up to 40–70% of storage cost |
| 9 | Serve static content from the edge | CloudFront in front of assets and cacheable pages: origin bandwidth and load drop | Cuts egress and server count |
| 10 | Use Spot for interruptible work | Background workers and batch jobs that can safely stop and restart (never the main database) | Up to about 90% off (often 60–70% in practice) |
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
| Path | Approx. price | Design consequence |
|---|---|---|
| Internet → AWS (inbound) | Free | Uploads cost nothing to receive |
| AWS → internet, from EC2/ALB | First 100 GB/month free, then about $0.109/GB | Serve big files from S3 + CloudFront instead |
| S3 → CloudFront | Free | The CDN is often cheaper than serving the bytes yourself |
| CloudFront → internet | First 1 TB/month free, then ~$0.11/GB (India) | Cache aggressively |
| Between Availability Zones | ~$0.01/GB each direction | Chatty cross-AZ traffic (app ↔ DB in another AZ) is a hidden tax |
| Through a NAT Gateway | ~$0.056/GB on top of the hourly charge | Send S3 traffic through a free gateway endpoint |
| Same AZ, private IPs | Free | Talk over private addresses, not public ones |
| Between regions | ~$0.02+/GB | Cross-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 Plan | Reserved Instance (RI) | |
|---|---|---|
| You commit to | A dollar amount per hour of compute for 1 or 3 years | A specific instance type/engine/region for 1 or 3 years |
| Flexibility | Applies across instance families, sizes, regions, even Fargate and Lambda | Tied to what you reserved (Convertible RIs bend a little) |
| Covers | EC2, Fargate, Lambda | EC2, 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.) |
| Discount | Up to 66% vs on-demand | Up to about 70%; commonly 30–60% |
| Payment | No upfront / partial / all upfront (more upfront = bigger discount) | Same options |
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:
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_tagsblock from Lesson 15 already putsProject,EnvironmentandManagedByon 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.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.
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.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.
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 infrastructureThe 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 for | Where | Why it bills |
|---|---|---|
| Unattached EBS volumes | EC2 → Volumes, state available | Disks left behind by terminated servers. Snapshot if unsure, then delete |
| Unattached Elastic IPs | EC2 → Elastic IPs, no instance | Still billed as public IPv4 |
| Old EBS and manual RDS snapshots | EC2 → Snapshots; RDS → Snapshots → Manual | Kept forever until deleted, including the drill copies |
| A forgotten NAT Gateway | VPC → NAT gateways | ~$40 a month each |
| Idle load balancers | EC2 → Load balancers, no requests | Hourly charge whether used or not |
| Log groups that never expire | CloudWatch → Log groups, retention Never expire | Storage grows every month |
| Instances in other regions | EC2 → EC2 Global View | The 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.
- User's browsertypes https://yourapp.com
- DNS: name → IP (Lesson 3, 13)Route 53answers with the CloudFront or ALB address
- static file? served from the edge (Lesson 11)CloudFront (CDN)cache near the user; passes dynamic requests on
- TLS ends here or at the ALB (Lesson 4)ALB (load balancer)picks a healthy server; Auto Scaling adds more under load
- inside your VPC, public subnet (Lesson 6, 12)EC2 · Nginxreceptionist on :80/:443 — forwards to the app on :3000
- 127.0.0.1:3000 (Lesson 7, 10)EC2 · PM2 → Next.js / Nodeyour code, kept alive and restarted on crash
- private subnet only (Lesson 8, 16)RDS (PostgreSQL) · Redis · S3data, cache/sessions, files — never reachable from the internet
- Your laptopgit push origin main
- GitHub receives the commitGitHub Actions (CI)installs, lints, runs tests, npm run build
- any step fails → stop here, nothing deployedDocker buildpackages app + Node + deps into one image, pushed to a registry
- same image runs on your laptop and on EC2Deploy (CD)EC2 pulls the image · or Terraform/ASG rolls new servers
- health check passes → old version retiredPM2 / container restartedzero-downtime reload
- Nginx keeps serving throughoutUserssee the new version — minutes after the push, no SSH
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:
| Piece | Lesson | Job | If it fails… | Cost |
|---|---|---|---|---|
| Route 53 | 13 | Turns yourapp.com into the ALB / CDN address; health checks; private names | Nobody can find the site (multi-provider is the fix at scale) | ~$1–3 |
| CloudFront + S3 | 11 | Caches static files at the edge; stores uploads and assets privately | Images and assets slow or missing; app still works | ~$3–15 |
| ALB + ACM | 12, 4 | Terminates HTTPS, spreads traffic, health-checks targets | Site unreachable; AWS runs it across 2 AZs | ~$20–30 |
| Auto Scaling group + EC2 | 7, 9, 12 | Stateless app servers running the Docker image, replaced not repaired | One server dies → the ALB routes around it; ASG replaces it | ~$32–96 |
| VPC, subnets, SGs | 6 | The private building: public floor for the ALB and servers, private floor for data | Misconfiguration exposes data (the biggest risk) | Free |
| RDS PostgreSQL | 8 | The system of record: relational data with backups and point-in-time restore | App errors; restore or fail over. The one thing you cannot lose | ~$16–58 |
| ElastiCache (Valkey) | 16 | Cache, sessions, rate limits | Slower, users may need to log in again; app should fail open | ~$12–45 |
| IAM roles + OIDC | 5, 14 | Every machine and pipeline has short-lived, scoped credentials | Access denied errors; or, if too broad, a bigger breach | Free |
| ECR + GitHub Actions | 9, 14 | Builds, tests, ships immutable images; rollbacks by tag | Cannot deploy; running site unaffected | ~$1 + free tier |
| Terraform + S3 state | 15 | The whole estate as reviewed code | Cannot change infra; running site unaffected | Pennies |
| CloudWatch + SNS | 17 | Metrics, logs, dashboards and alerts that reach a human | You are blind, and nobody is told | ~$8 |
| CloudTrail, GuardDuty, backups | 18 | Detection, audit and recovery | Breaches 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:
| Area | Ready means |
|---|---|
| Reliability | At least 2 servers in 2 AZs; health checks tested by killing a server; RDS backups on and a restore practised; rollback rehearsed |
| Security | Lesson 18 checklist complete; nothing but the ALB public; no keys anywhere; MFA everywhere; secrets in SSM/Secrets Manager |
| Performance | Load tested at 2× expected peak; p95 known; DB connection budget computed at max scale; static assets on the CDN |
| Observability | Alarms on the four golden signals (latency, traffic, errors, saturation) tested; logs structured; dashboard exists; someone is on the alert address; runbooks linked |
| Operations | Everything in Terraform; deploys via the pipeline with an approval; a documented way to reach a server (SSM) |
| Cost | Budget alerts set; tags active; log retention set; no NAT unless justified; monthly review scheduled |
| People | At 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 scale | Often lower or equal | ~$35–130 in this design |
| Bill as traffic grows | Grows with usage; can spike | Mostly fixed steps; cheaper per user at scale |
| Your time to operate | Near zero | Real: patches, incidents, on-call, cost reviews. Budget several hours a month, and more when things break |
| Long jobs, workers, websockets, big uploads | Limited or awkward | No limits |
| Database and network control | Limited | Complete |
| Compliance, data residency, private networking | Depends on the plan | Full control |
| Blast radius of your own mistakes | Small | Large: you can delete production |
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:
| Direction | What to learn | Why |
|---|---|---|
| Fewer servers to run | ECS on Fargate, App Runner, Lambda | Run your containers without managing servers yourself. This is the natural next step after Lesson 9 |
| Bigger orchestration | Kubernetes (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 code | Terraform modules and testing, AWS CDK, Pulumi | Reuse code and stay safe at scale (AWS CDK and Pulumi let you write infrastructure in a normal programming language) |
| Multi-account | AWS Organizations, Control Tower, SCPs, IAM Identity Center for all | Keep environments apart and limit the damage of one mistake (SCPs are rules that cap what every account may do) |
| Deeper data | Aurora, read replicas, DynamoDB, OpenSearch, data pipelines | For when one Postgres instance is no longer enough |
| Better operations | OpenTelemetry, SLOs, incident response, chaos testing | Treat 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) |
| FinOps | Cost allocation, showback (showing each team its own costs), commitment strategy | Treat cost as an engineering practice (FinOps = managing cloud money well) |
| Credentials | AWS Solutions Architect Associate, then Professional or DevOps Engineer | A 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
| Lesson | The sentence to remember |
|---|---|
| Lesson 0 | AWS gives you raw building blocks; Vercel gave you a finished house — the price of control is responsibility. |
| Lesson 1 | Every server is Linux: learn the shell, permissions, users and processes, or nothing else is debuggable. |
| Lesson 2 | A request is IP → port → firewall → app; “timed out” means blocked, “refused” means nothing is listening. |
| Lesson 3 | DNS is a cached phone book; TTL is your rollback speed. |
| Lesson 4 | HTTPS is a certificate chain of trust; let Let’s Encrypt and ACM do the renewing. |
| Lesson 5 | IAM is deny-by-default; machines wear roles, humans use MFA, nobody holds long-lived keys. |
| Lesson 6 | A subnet is public only because of one route-table row; data lives where no route reaches. |
| Lesson 7 | A server is a rented Linux box; the manual deploy is the blueprint for every automation. |
| Lesson 8 | Managed Postgres moves patching and backups to AWS, never your schema, queries or restores. |
| Lesson 9 | A container is the whole box shipped once: build small, tag by SHA, keep secrets out. |
| Lesson 10 | Nginx is the receptionist: TLS, compression, limits — and your app stays private. |
| Lesson 11 | Files live in S3 and reach users through a CDN; version file names, do not invalidate. |
| Lesson 12 | Scale by making servers stateless, cloning them behind an ALB, and testing by breaking them. |
| Lesson 13 | Route 53 aliases make the bare domain point at AWS; weighted DNS is the safest migration. |
| Lesson 14 | A pipeline is your manual deploy written down, with tests as a gate and OIDC as the key. |
| Lesson 15 | Terraform is the blueprint: read every plan, guard the state, protect stateful resources. |
| Lesson 16 | Redis is a shared whiteboard, never the only copy — cache with TTLs, fail open. |
| Lesson 17 | Alert on symptoms with runbooks; logs are structured, tenant-tagged and never hold secrets. |
| Lesson 18 | Assume breach: layers, least privilege, detection, and a backup you have actually restored. |
| Lesson 19 | Cost 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.
- 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.
- 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.
- Deploy an app through the pipeline, then break it with a bad release and recover with the rollback workflow. Record the time to recover.
- 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.
- Do the restore drill and write down the RTO and RPO you measured.
- Price it with the AWS Pricing Calculator, compare with your actual first-week bill in Cost Explorer, and explain any difference over 10%.
- 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.
- 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:
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.
Destroy what Terraform created
Infrastructurecd infra && terraform plan -destroy -var-file=prod.tfvarsRead the list of what will be deleted — this is the plan you most want to read
terraform destroy -var-file=prod.tfvarsRemove prevent_destroy and deletion_protection on the database first if this really is a practice account (Lesson 15)
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).
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