Learn Terraform by running it. Work through the lessons in order and you'll go from your first HCL file to production infrastructure as code — providers, resources, variables, outputs, state, modules, testing, CI/CD, and security. Every lesson is config you write and commands you run.
This course teaches Terraform by provisioning real things from the command line — so you need comfort in a terminal. You do NOT need a cloud account: every hands-on example uses the local, random, and docker providers, which run on your own machine. New to the command line? Do the Linux course first.
Before you start
You need the Terraform CLI. Install it for your OS, then confirm the version. No cloud account is required — the examples use local providers.
Windows
Via winget.
winget install -e Hashicorp.TerraformmacOS
Via Homebrew.
brew tap hashicorp/tap
brew install hashicorp/tap/terraformLinux
Via the HashiCorp apt repo.
sudo apt install terraformConfirm it works, then create an empty folder to build in:
terraform version
mkdir tf-lab
cd tf-labYour First Terraform Project
Write your first HCL, then run the core loop every Terraform project lives by — init, plan, apply, destroy — using local providers so you need no cloud account.
Providers
Providers are the plugins that let Terraform manage real things. Find them on the Registry, configure them, and pin their versions so your builds stay reproducible.
Resources & Dependencies
Resources are the things Terraform creates. Reference one from another to build dependencies, control replacement with lifecycle, and reach for provisioners only as a last resort.
Variables
Stop hardcoding values. Declare typed input variables, set them with .tfvars files and environment variables, and reject bad input with validation rules.
Outputs & Local Values
Surface useful values after an apply with outputs, mark sensitive ones so they stay out of logs, and tidy repeated expressions into named local values.
Meta-Arguments: count & for_each
Create many resources from one block. Use count for simple numbered copies, for_each for a keyed set, and conditional creation to turn a resource on or off.
Data Sources & Templates
Read information Terraform does not manage with data sources, and render configuration files from variables with templatefile — keeping generated config in step with your infrastructure.
State
State is how Terraform remembers what it built. Inspect and surgically edit it, store it remotely with locking for teams, and import resources that already exist.
Modules
Package configuration into reusable modules. Build a local child module with inputs and outputs, call it many times, and pull battle-tested modules from the Registry.
Format, Validate, Lint & Test
Keep configurations clean and correct — auto-format with fmt, catch errors with validate, enforce best practices with TFLint, and assert behavior with native terraform test.
Workflow, Workspaces & CI/CD
Run Terraform the way teams do — saved plans applied exactly, multiple environments with workspaces, and an automated pipeline that plans on every PR and applies on merge.
Security & Compliance
Ship infrastructure safely — keep secrets out of code and state, scan configurations for misconfigurations with tfsec, Checkov, and KICS, and enforce rules with policy as code.