Terraform · a build-along course
Don't read about Terraform.
Build something with it.
This course has one project, not a list of topics. You start with an empty AWS account and finish with ShopLite running in production: a VPC, containers behind a load balancer, a private database, remote state, reusable modules, separate dev and prod environments, and a CI pipeline that plans every pull request. Every mission adds one piece, and you see every file and every command along the way.
How every mission works
- 01
Mission briefing
A concrete goal, how long it takes, and what it costs to run on AWS.
- 02
Understand it first
The ideas explained properly — how Terraform actually behaves, not just which flag to type.
- 03
Project tree
Your ShopLite repo after the mission, with every new and modified file marked.
- 04
Build step by step
Exact file contents and commands, plus the output you should see — so you know you're on track.
- 05
Break it on purpose
Make a deliberate mistake, read the real error, diagnose it, then reveal the fix.
The build
- 0
First Apply
4 missionsSet up the ShopLite repo, create your first real AWS resource with Terraform, learn to read a plan like a reviewer, and make the config reusable.
+ ShopLite gains:a Terraform repo, an S3 assets bucket with versioning and public access blocked, and variables/outputs — all created by
terraform apply - 1
State
4 missionsOpen Terraform's memory, move it off your laptop into S3 with locking, reconcile drift and adopt existing resources, and rename things without destroying them.
+ ShopLite gains:a bootstrap config for a versioned, encrypted state bucket; remote state with S3-native locking; an imported CloudWatch log group; safely renamed resources
- 2
Network
4 missionsBuild ShopLite's VPC in code: subnets generated with for_each and cidrsubnet, internet and NAT routing, tiered security groups, and a probe instance that proves it all works.
+ ShopLite gains:a two-AZ VPC with public, private, and database subnets, an internet gateway, toggleable NAT, an S3 gateway endpoint, and ALB → app → DB security groups
- 3
Compute
4 missionsShip the ShopLite API: an image in ECR, an Application Load Balancer with optional HTTPS, ECS Fargate tasks with least-privilege roles, autoscaling, and versioned deploys.
+ ShopLite gains:the ShopLite API on ECS Fargate behind an ALB with a public URL, images in ECR, optional HTTPS with ACM + Route 53, autoscaling, and versioned deploys via
image_tag - 4
Data & Secrets
4 missionsGive ShopLite a Postgres database without a password ever touching your code or state, protect stateful resources from accidental destruction, and add private uploads with least-privilege IAM.
+ ShopLite gains:RDS Postgres in the database subnets with an AWS-managed master secret, the API reading its credentials from Secrets Manager, lifecycle guardrails and health checks, and a private uploads bucket with presigned uploads
- 5
Modules
4 missionsTurn ShopLite's growing pile of .tf files into reusable modules — extracted with zero downtime, designed with typed interfaces, versioned, and instantiated with for_each.
+ ShopLite gains:a
networkmodule, anecs-servicemodule running the API and a new worker, git-tagged module versions, and services defined as a single map - 6
Environments
4 missionsRun the same ShopLite code as isolated dev and prod environments: separate state, separate tfvars, separate AWS accounts with guards against applying to the wrong one, and a safe way to share outputs.
+ ShopLite gains:per-environment backends and tfvars behind a small wrapper script, a prod environment in its own AWS account with
allowed_account_ids, aus-east-1provider alias for billing alarms, and outputs published to SSM for other teams - 7
Team Workflow
4 missionsTake Terraform off laptops: plans on every pull request, gated applies from CI with no stored keys, tests and static analysis, policy checks on plans, and the day-2 routines that keep it all healthy.
+ ShopLite gains:a GitHub Actions pipeline (plan on PR, gated apply on merge) using OIDC roles, tflint + trivy +
terraform test, an OPA policy gate on plans, nightly drift detection, and a documented teardown