Terraform
Terraform is the reconcile loop you saw in Kubernetes, applied to infrastructure: a desired-state file, a state file, and a diff engine. Understand state and Terraform stops surprising you. We use the local provider — no cloud, no cost.
local provider so nothing is provisioned in the cloud.You declare what should exist; plan diffs that against reality and shows the delta before touching anything.
Declare a local_file resource and plan it.
$ terraform planThe plan shows 1 to add — the gap between your desired state and the empty world.
Reveal solution
$ cat > main.tf <<EOF resource "local_file" "hello" { content = "built by terraform" filename = "\${path.module}/out.txt" } EOF $ terraform init $ terraform plan
apply makes reality match desired state and records what it did in terraform.tfstate — Terraform's memory of the world.
Apply, then look at the state.
$ test -f out.txt && echo createdThe file exists and terraform.tfstate (JSON) now records the resource. State is how Terraform knows what it owns.
Reveal solution
$ terraform apply -auto-approve $ cat out.txt $ jq .resources[0].instances terraform.tfstate
Change a managed resource by hand and Terraform notices: plan shows drift, apply reconciles it back.
Edit the file outside Terraform, then plan.
$ terraform planPlan reports the file changed and offers to restore it — desired-state reconciliation, exactly like a Kubernetes controller.
Reveal solution
$ echo tampered > out.txt $ terraform plan # shows drift $ terraform apply -auto-approve # restores desired state
Reach engineers who read the man page
Native, contextual, no tracking — this is how the curriculum stays free.
When one resource references another, Terraform builds a DAG and orders operations correctly — the same kind of dependency graph this whole curriculum is organised by.
Make one resource reference another and render the graph.
$ terraform graphThe output shows an edge from the dependent resource to the one it references — Terraform figured out the order for you.
Reveal solution
# add a second local_file whose content references local_file.hello.content $ terraform graph | grep -i local_file
Desired state, a state file, plan/apply, drift, a dependency DAG — Terraform is Kubernetes' reconcile idea for infrastructure. The mental model transfers directly; only the objects change.