Terraform Mastery: A Practical Learning Path
A structured self-study path for Terraform — theory, hands-on labs, and a real project, from initial setup through production-grade infrastructure.
A structured Terraform learning path that combines theory, hands-on labs, and a real project. Everything here is stuff that comes up in actual work.
What you'll be able to do
After finishing the series, you'll be comfortable with:
- Writing production-grade Terraform with clean, well-structured modules.
- Managing state safely — remote backends, locking, state surgery, import.
- Designing reusable modules with versioning and publishing.
- Handling multiple environments (dev/staging/prod) the right way.
- Writing tests for infrastructure — terraform test, tflint, checkov, terratest.
- Plugging Terraform into a CI/CD pipeline — GitHub Actions, GitLab CI, Atlantis.
- Dealing with drift and refactoring safely using moved/import/removed blocks.
- Applying security practices: secrets management, policy-as-code, least privilege.
Learning roadmap
┌─────────────────────────────────────────────┐
WEEKS 1-2 │ 00. Setup → 01. Fundamentals │
(Foundations) │ 02. State → 03. Variables/Outputs │
└─────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────┐
WEEKS 3-5 │ 04. Expressions/Functions/Data sources │
(Intermediate) │ 05. Loops & Conditionals │
│ 06. Modules │
└─────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────┐
WEEKS 6-9 │ 07. Multi-env & Workspaces │
(Advanced) │ 08. Testing & CI/CD │
│ 09. Security/Secrets/Drift/Refactoring │
└─────────────────────────────────────────────┘
│
┌─────────────────────────────────────────────┐
WEEKS 10-12 │ 10. Capstone Project (3-tier production) │
(Production) │ Cheat sheet + review │
└─────────────────────────────────────────────┘
The week numbers are a rough guide, not a hard schedule. Go at whatever pace works for you. The only rule: type out every line of code yourself. Don't copy-paste.
Module index
| # | Module | Topics | Level |
|---|---|---|---|
| 00 | Setup & Environment | Install Terraform, providers, safe practice env (LocalStack) | ⭐ |
| 01 | Fundamentals | HCL, providers, resources, plan/apply, lifecycle | ⭐ |
| 02 | State Management | State file, remote backend, locking, import | ⭐⭐ |
| 03 | Variables & Outputs | variable, output, locals, validation, sensitive | ⭐⭐ |
| 04 | Expressions & Functions | functions, data sources, dependency, dynamic | ⭐⭐ |
| 05 | Loops & Conditionals | count, for_each, for, dynamic blocks, conditionals | ⭐⭐⭐ |
| 06 | Modules | module design, versioning, registry, composition | ⭐⭐⭐ |
| 07 | Multi-Environment | workspaces vs directories, DRY, partial backend | ⭐⭐⭐ |
| 08 | Testing & CI/CD | terraform test, tflint, checkov, GitHub Actions | ⭐⭐⭐⭐ |
| 09 | Security & Refactoring | secrets, OPA, drift, moved/import/removed | ⭐⭐⭐⭐ |
| 10 | Capstone Project | 3-tier production infrastructure, multi-env, CI/CD | ⭐⭐⭐⭐⭐ |
Reference materials:
- Cheat Sheet — quick command and syntax lookup
- Interview Questions — 60+ questions with answers
- Skill Checklist — self-assessment at each level
Directory structure
terraform-mastery/
├── README.md
├── 00-setup/
├── 01-fundamentals/
│ ├── README.md ← theory
│ └── hands-on/ ← runnable code + lab guide
├── 02-state-management/
├── ... (other modules)
├── 10-capstone-project/
└── reference/
├── cheat-sheet.md
├── interview-questions.md
└── skill-checklist.md
Each module follows the same pattern:
README.md— the theory section: explains the "why", diagrams, best practices, common mistakes.hands-on/—.tfcode you can actually run, plusLAB.mdwith step-by-step instructions and exercises.
Prerequisites
- Basic familiarity with cloud concepts (AWS/Azure/GCP) — AWS is used throughout.
- Comfortable with terminal/command line.
- Basic Git knowledge.
- (Helpful) Some understanding of networking (VPC, subnet, security group) and Linux.
You don't need a paid AWS account. Module 00 covers LocalStack — a local AWS emulator that lets you practice for free without any risk of surprise charges.
How to get the most out of this
- Read the README for each module to get the concepts.
- Do the hands-on lab — type the code yourself, run
plan/apply, see what happens. - Break things intentionally — introduce errors on purpose, read what Terraform says, then fix it.
- Do the exercises without peeking at the answers first.
- Explain it back to yourself in plain language (Feynman technique).
- At the end of each week, go through the Skill Checklist.
The philosophy behind this series
"You don't learn Terraform by reading about it. You learn it by running
terraform apply, corrupting a state file, and figuring your way out."
Every lab has:
- A clear objective
- Complete, runnable code
- A "break it" scenario based on real mistakes
- Exercises without provided solutions
- Completion criteria so you know when you're actually done