cd ~/tutorials/terraform

Terraform Tutorial

Learn Terraform 1.17 from zero: write infrastructure as code, manage state safely, build reusable modules, ship to AWS from a CI pipeline and keep secrets out of your state file.

15 lessons · 101 min

Start the course →

This course takes you from “what is infrastructure as code?” to running Terraform from a CI pipeline with tests, policies and no long-lived cloud keys. All along you build the infrastructure for Orbit, a small notes app: a web front end, an API and a cache, then a storage bucket and a server on AWS.

Lessons 1 to 11 run against Docker on your own machine, so you can practise every command for free without a cloud account. Lesson 12 moves the same ideas to AWS. Every lesson has configurations you can copy, two quick exercises and answers to the questions people ask most.

Before you start: you need Docker installed and running. If docker run is new to you, do the Docker Tutorial first. Lesson 2 shows how to install Terraform on Windows, macOS and Linux.

The examples target Terraform 1.17 (October 2026) and point out which features arrived in which version, so you can tell what works on an older team setup.

ls ./lessons

  1. Introduction to TerraformWhat Terraform is, the problems infrastructure as code solves, how plan and apply work, what changed in the Terraform world up to version 1.17 and how it compares with Ansible, CloudFormation, Pulumi and OpenTofu.beginner8 min readCompleted
  2. Installing TerraformInstall Terraform 1.17 on Windows, macOS and Linux, manage several versions per project with tenv, set up your editor and run a first configuration that needs no cloud account.beginner6 min readCompleted
  3. The Terraform Core WorkflowRun init, fmt, validate, plan, apply and destroy on a real Docker setup, read a plan symbol by symbol, save plans to files and use refresh-only, replace and the new minimal refresh mode.beginner8 min readCompleted
  4. Terraform Variables and OutputsMake one configuration serve every environment with typed input variables, validation rules, locals and outputs, and learn the modern options: sensitive and ephemeral values, deprecation warnings, typed outputs and const variables.beginner7 min readCompleted
  5. Terraform State and BackendsWhat the state file holds and why Terraform needs it, how to store it remotely with locking on S3 (no DynamoDB needed any more) or HCP Terraform, and how to refactor safely with moved, removed and the new destroy = false.intermediate7 min readCompleted
  6. Terraform ModulesPackage infrastructure into reusable modules, call them from local folders, Git or the Registry, pin versions, test them with terraform test and use the 1.15 and 1.16 additions such as const sources and import blocks inside modules.intermediate7 min readCompleted
  7. Terraform Data SourcesRead information about infrastructure Terraform does not manage, pin images by digest, look up cloud IDs instead of hard-coding them, fetch secrets with ephemeral resources, and adopt existing objects with import blocks and terraform query.intermediate7 min readCompleted
  8. Terraform count and for_eachCreate many similar resources from one block, understand why count can recreate the wrong things when a list changes, use for_each with maps and sets, move between the two safely and fix the Invalid for_each argument error.intermediate6 min readCompleted
  9. Terraform Expressions and FunctionsWrite conditionals, for expressions, splats and templates in HCL, use the built-in functions you need most, experiment safely in terraform console and use newer additions such as provider-defined functions, templatestring and convert.intermediate6 min readCompleted
  10. Terraform Dynamic BlocksGenerate repeated nested blocks such as ports, volumes and firewall rules from variables with dynamic blocks, handle optional blocks, and learn when separate resources with for_each are the better design.intermediate6 min readCompleted
  11. Terraform WorkspacesRun several copies of one configuration with separate state using CLI workspaces, see where their state lives, decide between workspaces, folders per environment, HCP Terraform workspaces and Stacks, and avoid the classic mistakes.intermediate6 min readCompleted
  12. Terraform with AWSConnect Terraform to AWS without access keys in code, use AWS provider 6 features such as per-resource regions and default tags, and build Orbit's upload bucket and a hardened web server you reach through Session Manager instead of SSH.intermediate7 min readCompleted
  13. Terraform ProvisionersHow local-exec, remote-exec and file provisioners work, why HashiCorp calls them a last resort, how to run scripts cleanly with terraform_data, and how the newer actions feature (1.14 to 1.16) replaces many provisioner use cases.intermediate6 min readCompleted
  14. Terraform CI/CD PipelineBuild a GitHub Actions pipeline for Terraform with OIDC instead of stored keys, plan on every pull request, tests and policy checks, a human approval before apply, saved plans and a nightly drift check.advanced7 min readCompleted
  15. Terraform SecurityKeep secrets out of state with ephemeral values and write-only arguments, lock down state and credentials, pin providers and modules against supply chain attacks, scan code and enforce rules with Terraform Policy.advanced7 min readCompleted

↑ ↓ navigate Enter open Esc close