linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Knowledge base
  • Cheat sheet
  • Capstone
  • Interview prep

§ how it works · terraform

How Terraform works. Animated.

Each card below is a step-by-step SVG visualization of one Terraform concept. What happens to your HCL, your state file, and the real cloud at each step of plan, apply, and destroy. Good for the "it works but I don't get why" moments.

These are drawn diagrams, not a sandbox. To get hands-on, go to the lessons on LocalStack.

  • workflow · 6 steps

    The core Terraform cycle: init → plan → apply → destroy

    What Terraform does on each command. The three sources of truth (HCL, state, the cloud), how they line up and drift apart, and why apply without plan is a bad habit.

    view→
  • workflow · 6 steps

    Dependency graph: what Terraform runs in parallel and what it blocks

    How Terraform learns the order to create resources in. The graph built from implicit refs, parallel "layers", and why destroy runs in exactly the reverse direction.

    view→
  • state · 6 steps

    Anatomy of terraform.tfstate

    What lives inside the state file, why serial and lineage are there, and why a password from HCL ends up as plain text in it. The full JSON, layer by layer.

    view→
  • state · 6 steps

    Drift: when state and reality diverge

    Someone changed a tag in the AWS Console, and Terraform suddenly shows changes. What drift is, why it happens, and three ways to live with it.

    view→
  • state · 5 steps

    Remote backend and lock: how two engineers work with one state

    S3 stores the state, DynamoDB holds the lock. What happens when two people run apply at the same time, and why a "team of one" is the only case where you can live without this.

    view→
  • state · 6 steps

    Plan as a three-way diff: HCL vs state vs cloud

    What terraform plan actually compares. Why it refreshes, how three sources become one plan, and what -refresh=false hides.

    view→
  • state · 5 steps

    state mv, state rm, import: imperative operations on state

    Three commands that edit the state file directly: rename an entry, forget a resource, pull an existing one in from the cloud. What they change, what they leave alone, and where they bite.

    view→
  • state · 5 steps

    moved, removed, import: the same operations, but in HCL

    Declarative blocks for renaming, dropping, and pulling in resources. What they give you beyond the CLI, which Terraform versions added them, and why they live in git.

    view→
  • resources · 5 steps

    count vs for_each: why deleting one user breaks the rest

    Two ways to create N identical resources. One indexes by number, the other by key. Deleting the middle of the array produces completely different plans.

    view→
  • resources · 6 steps

    lifecycle: four levers for managing a resource

    create_before_destroy for zero-downtime, prevent_destroy for the critical stuff, ignore_changes for drift, replace_triggered_by for cascading rebuilds. What each one does in practice.

    view→
  • variables · 6 steps

    Where Terraform gets a variable's value

    Six value sources for one variable, lined up in a queue. Which one overrides which, and why your .tfvars sometimes "doesn't apply."

    view→
  • modules · 6 steps

    Modules: how variables flow down and outputs flow up

    What happens at the root → child module boundary: input through variable, output through output, and why a module stays reusable only if it does not reach for global providers.

    view→
  • cicd · 6 steps

    plan as an artifact: a pipeline with review between plan and apply

    Save tfplan to a file, show it to a human, apply exactly that file, and stop a different diff from sneaking through by accident. The canonical CI pattern for Terraform.

    view→
  • cicd · 6 steps

    OIDC: GitHub Actions into AWS without long-lived keys

    The workflow gets a short JWT from GitHub, exchanges it for temporary STS creds, runs Terraform, and an hour later all of it just disappears. No access-key secrets.

    view→
  • cicd · 6 steps

    Policy gate: blocking violations between plan and apply

    An engine sits between the plan and apply steps: Checkov, OPA, or Sentinel. It reads plan.json and decides whether the change can be applied. A bucket with no encryption simply will not pass.

    view→
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies