InfraMaxx

Track

Terraform & IaC lessons

43 short lessons on Terraform & IaC. Each one starts from a real situation, shows how it works, and ends with a quiz. Free to read.

Start with the first lesson

All 43 lessons

  1. Infrastructure as code: why and what declarative meansBeginner · 5 min

    Why a security group nobody can explain is a bigger risk than one that is misconfigured, and how describing the end state in a file lets a tool find the gap for you.

  2. The Terraform workflow: init, plan, apply, destroyBeginner · 5 min

    Four commands, one rule: read the output of the second before you run the third. Create a bucket, prove nothing is left to change, then delete it again.

  3. Variables, outputs and localsBeginner · 5 min

    One set of files, two environments: how variables, locals and outputs let the same code build staging and prod, and which source of values wins when two disagree.

  4. Terraform state: what it maps and why it mattersBeginner · 5 min

    A pull request that only renames a resource label plans to delete a bucket holding 90 GB of logs. State explains why, and one moved block fixes it.

  5. Remote state and lockingBeginner · 5 min

    Two engineers apply within seconds of each other. Without a shared state and a lock, one run overwrites the other's record. Here is how the second one gets stopped…

  6. Lifecycle ignore_changesBeginner · 4 min

    Lifecycle ignore_changes suppresses plans for selected attribute drift.

  7. create_before_destroyBeginner · 4 min

    create_before_destroy requests replacement creation before deletion.

  8. Providers and version lockingBeginner · 5 min

    Why a pipeline that passed for three months can start changing 14 resources on a Monday, and the two files that stop it.

  9. Modules: reuse without copy-pasteBeginner · 5 min

    Fourteen log buckets across five repos, three different encryption settings, and an audit question nobody can answer. A module turns that into one definition.

  10. Terraform workspaceBeginner · 4 min

    Terraform workspace separates multiple state instances.

  11. Data sourcesBeginner · 5 min

    Data sources read existing infrastructure for configuration.

  12. Reading a plan: create, change, destroy and replaceBeginner · 5 min

    The summary line of a plan counts replacements twice. How to read every symbol, find the attribute that forced a replacement, and spot drift.

  13. terraform importBeginner · 4 min

    terraform import associates existing infrastructure with state.

  14. Terraform refreshBeginner · 4 min

    Terraform refresh reads current provider objects into planning.

  15. Moved blocksBeginner · 4 min

    Moved blocks record resource address refactors.

  16. IAM policy for automationBeginner · 4 min

    IAM policy for automation bounds Terraform permissions.

  17. S3 remote backendBeginner · 4 min

    S3 remote backend persists Terraform state in an S3 object.

  18. Plan approvalsBeginner · 4 min

    Plan approvals gate changes before production apply.

  19. Terraform init and providersBeginner · 4 min

    terraform init installs the providers and modules a configuration needs and sets up its backend, and the committed lock file keeps every run on the same provider…

  20. Dependency graphIntermediate · 4 min

    Terraform builds a dependency graph from references and explicit depends_on lines, and the graph sets the order of work and decides which resources can run in parallel.

  21. State lockingIntermediate · 4 min

    A supported backend locks Terraform state to coordinate operations that could write it.

  22. Remote backendsIntermediate · 5 min

    A backend stores Terraform state in shared storage and can lock it so two runs cannot write the same state, and that state holds secrets that need the same protection…

  23. Drift detectionIntermediate · 4 min

    Drift is a difference between Terraform's state and the real infrastructure, and a refresh-only plan shows it without changing anything, though a plan with refresh…

  24. Plan versus applyIntermediate · 4 min

    A plan is a proposal, and a saved plan file holds the reviewed actions that apply performs without a new prompt, which keeps the approval and the change tied together.

  25. Resource lifecycleIntermediate · 4 min

    Lifecycle settings control replacement order, destruction guards and ignored attributes, so each setting decides whether a change replaces a live resource safely or is…

  26. for_each identityIntermediate · 4 min

    for_each identifies each instance by its map key or set element, so renaming a key looks like destroying one object and creating another unless the move is recorded.

  27. count indexingIntermediate · 4 min

    count identifies instances by index, so reordering or removing a list item can change which live object each index points to, and the plan can replace them.

  28. Import existing resourcesAdvanced · 4 min

    Import records an existing object in state without changing it, and a clean plan afterwards shows the configuration matches the real object so the team can manage it.

  29. Module contractsAdvanced · 4 min

    A module's input variables and output values form its contract with callers, so renaming an output or removing an input breaks callers even when the module code is…

  30. Output sensitivityAdvanced · 4 min

    A sensitive output is hidden on screen and in logs, but Terraform still stores the value in state, so the state store and the CI logs need the real protection.

  31. Secret handlingAdvanced · 5 min

    Secrets in Terraform reach state and plan files even when they are marked sensitive, so a handling plan must cover where values are stored, who can read them and how…

  32. Provider aliasesAdvanced · 4 min

    Provider aliases give one provider several configurations, and resources and modules must pick one explicitly because the default is used without warning when they do…

  33. Multi account providersAdvanced · 4 min

    Multi-account Terraform works when each provider configuration assumes a role in its own account, because an assumed session carries that role's permissions and then…

  34. Workspaces limitationsAdvanced · 4 min

    Workspaces hold separate states inside one backend and one configuration, which makes them a weak barrier between environments that need separate credentials, so use…

  35. Policy as codeAdvanced · 4 min

    Policy as code checks Terraform plan data against written rules before changes are applied, and it protects a team only when the rules are tested and fail on a known…

  36. OPA and SentinelAdvanced · 4 min

    OPA and Sentinel are policy frameworks that evaluate rules against plan data, and the right choice depends on whether the checks run inside HCP Terraform or in your own…

  37. Terraform testingAdvanced · 4 min

    Explain how Terraform's built-in test files check a module's behaviour. Plan-mode runs read planned values cheaply, while apply-mode runs create real infrastructure and…

  38. State recoveryAdvanced · 5 min

    Explain how to recover Terraform state when a real object and its state entry disagree. Back up state first, then edit the state map and plan again before any apply.

  39. Destroy planningAdvanced · 4 min

    Explain how to build, save and read a Terraform destroy plan before anything is deleted. The saved plan shows exactly what the destroy will remove, and only that file…

  40. Terragrunt orchestrationAdvanced · 4 min

    Explain how Terragrunt runs many Terraform units in dependency order and passes outputs between them. Mock outputs and wide run scopes are the two places where a run…

  41. IaC code reviewAdvanced · 4 min

    Explain how to review a Terraform change by its plan, not just its diff. Formatting and validate checks are cheap, but access and network changes need a reader who…

  42. Output sensitivity: failure analysisAdvanced · 4 min

    Explain what the sensitive flag on a Terraform output does and does not protect. The value is hidden in display output but still written to state, plan files and…

  43. Secret handling: operational verificationAdvanced · 4 min

    Explain how to verify that a secret stays out of the places it should not reach. A repeatable test with a dummy value searches state, plans and logs before merge.