← All bricks

terraform · Beginner

terraform: Infrastructure as Code, the Core Loop

Learn the Terraform core workflow hands-on — write HCL, init providers, plan, apply, inspect state, parameterise with variables and outputs, loop with for_each, and destroy. No cloud account required.

Terraform turns infrastructure into code you can read, review and re-run. This course walks the core loop one small move at a time: you write a tiny configuration, initialise its providers, format and validate it, preview the change with plan, apply it, and read the state Terraform keeps. From there we make the config real — variables, a tfvars file, outputs, the console, and a for_each loop — and finish by saving a plan, targeting a single resource, and tearing everything down with destroy. Everything runs against the local and random providers, so there are no credentials and nothing to clean up in the cloud: just real Terraform, end to end.

What you'll build

  • Write a Terraform configuration and initialise its providers
  • Format, validate and preview changes with fmt, validate and plan
  • Apply changes and read the state Terraform records
  • Parameterise a config with variables, tfvars and outputs
  • Create many resources at once with for_each
  • Save a plan, target a resource, and destroy what you built

Contents

  1. Check your Terraform
  2. Describe what you want
  3. Initialise the project
  4. Tidy the formatting
  5. Check it makes sense
  6. Preview the change
  7. Apply it
  8. See what it made
  9. Read the recorded state
  10. List what's tracked
  11. Inspect one resource
  12. Make the greeting a variable
  13. Wire the variable in
  14. Plan an override
  15. Set values in a file
  16. Apply the new value
  17. Confirm the change
  18. Declare some outputs
  19. Read the outputs
  20. Read a single output
  21. Open the console
  22. Evaluate expressions
  23. Make many at once
  24. Plan the loop
  25. Save a plan
  26. Apply the saved plan
  27. See the full inventory
  28. Target one resource
  29. Tear it all down
  30. Decide what to commit