Skip to content

Terraform Learning

A working notebook, not a tutorial. Everything here was written while learning Terraform against a real GCP project — the labs record what was actually run, the quiz questions come out of things that actually broke, and the session notes record the wrong answers as well as the right ones.

If you are looking for a specific concept rather than a place to start, go straight to the concept index — it maps every concept to its theory page, its local lab, its GCP lab, the sandbox file that uses it for real, and the quiz that tests it.

The path

Four stages, ordered by what it costs you to be wrong — which turns out to be the same as ordering by complexity.

Stage What it is Needs Costs
1 Theory 19 pages of definitions and mechanics, in dependency order — providers, state, expressions, modules, backends, the execution model nothing nothing
2 Basics 13 topics using local/random/null/archive. Real Terraform lifecycle, files on disk instead of cloud resources Terraform nothing
3 GCP A full Terraform root against a real project, plus 18 lab notes — remote state, modules, workspaces, import, drift a GCP project cents
4 Sandbox Five interdependent Terraform roots, a Consul contract, GKE, Cloud SQL, Helm, Workload Identity GCP + patience real money

Test yourself at any point with the quiz (33 questions across 6 topics), and read the session log for the narrative version — what was attempted, what failed, and why.

Every topic, in order

Stage 1 — Theory · nothing to install

Read in order; each page assumes only the one before it.

# Page # Page
1 What Terraform is 11 Data sources
2 Providers and authentication 12 Modules
3 init and version constraints 13 State lifecycle
4 Resources and state 14 Backends and state security
5 Resource identity and change 15 Cross-config composition
6 Dependencies and the graph 16 GitOps and CI/CD
7 Variables and locals 17 Project structure
8 Expressions and conditionals 18 CLI reference
9 count, for_each, dynamic 19 Glossary
10 Outputs

Stage 2 — Basics · no cloud, no cost

# Topic Code
1 Resources and state 01-basics/1-create-local-file/
2 Variables 01-basics/2-variable-use/
3 Locals
4 References and dependencies 01-basics/3-, 01-basics/4-dependencies/
5 Outputs 01-basics/4-dependencies/explicit/
6 Data sources 01-basics/6-data-sources/
7 count and for_each
8 Conditionals
9 Lifecycle 01-basics/5-lifecycle/
10 Validation and sensitive values
11 Provider versions 01-basics/7-version-constraints/
12 State surgery
13 Provisioners and archive_file

Stage 3 — GCP · cents

Page Code
Prerequisites and cost
Core GCP root 02-gcp-terraform/01-core-gcp-resources/
Lab notes 1–18 acme-sampleapp-…/

Stage 4 — Sandbox · real money

Page Code
The acme-sampleapp sandbox acme-sampleapp-…/
Runbook apply order, Consul dev agent, teardown

Code in this repository

01-basics/             8 local Terraform roots in 7 folders. No cloud, no auth, no cost.
02-gcp-terraform/      The same concepts against a real GCP project.
acme-sampleapp-.../    5 interdependent roots, Consul, GKE, Cloud SQL, Helm.

The code directories contain .tf files, plus a checked-in graph.svg in the two roots where the dependency graph is itself the lesson. Every explanation lives here in the docs, linked from the tables above, so there is one place to read and one place to run.

Running these docs locally

pip install -r requirements.txt
mkdocs serve

Or without installing anything into your environment:

uvx --with mkdocs-material mkdocs serve

Some pages embed diagrams generated from real Terraform state. To regenerate one (needs Graphviz):

terraform graph | dot -Tsvg > graph.svg