Skip to main content

Learn Terraform: From First Module to State, Drift and Multi-Environment Setups

Learn Terraform by building one small project, then adding the three things that hurt teams in production: shared modules, remote state and drift. Each step links a guide with real HCL and the exact commands to run.

Everything up to the State stage works against a free cloud account or local providers. The later stages assume a team sharing state.

  1. Stage 1: Foundations

    Write, plan and apply your first configuration.

    1. 1Terraform tutorial: your first IaC projectInit, plan, apply and destroy a real resource.
    2. 2Best infrastructure-as-code toolsKnow where Terraform sits next to Pulumi, OpenTofu and CDK.
    3. 3count vs for_eachCreate many resources without index drift.
  2. Stage 2: Structure

    Reusable modules and multiple environments.

    1. 4Module versioning and shared registriesPublish and pin modules other teams consume.
    2. 5Terragrunt explainedDecide if you need it for many environments.
    3. 6Import existing resourcesBring click-ops infrastructure under code.
  3. Stage 3: State and drift

    The part of Terraform that causes most incidents.

    1. 7Fix "Error acquiring the state lock"Unblock a stuck lock safely.
    2. 8Terraform state migrationMove state between backends and addresses.
    3. 9Fix Terraform driftReconcile code with what is actually deployed.
    4. 10Drift detection in CICatch drift on a schedule, not during an incident.
    5. 11When plan wants to replace your databaseRead a destructive plan before it runs.
  4. Stage 4: Troubleshoot and choose

    Error fixing and the platform decisions around Terraform.

    1. 12Terraform error troubleshooting guideFix the common plan and apply errors.
    2. 13Fix provider version conflictsResolve constraint and lock-file clashes.
    3. 14Terraform vs OpenTofuChoose after the license change.
    4. 15Terraform Cloud alternativesPick a runner for plans and applies.

Keep these open

Every guide on this path names the versions and docs it was checked against and lists its sources at the end. Browse all terraform guides or another learning path.