Lion Cipher Lab

Detect and reconcile Terraform drift

Why it matters

Infrastructure as Code only holds its promise while the code and the real infrastructure agree. The moment someone reaches past the code — clicks a fix in the cloud console at 2 a.m., runs a one-off script, lets another tool touch the same resource — the two quietly diverge. That gap is called drift, and it is dangerous precisely because it is invisible until it bites: your next deploy silently reverts an emergency fix, a security setting someone tightened by hand gets loosened back to what the code says, or an audit finds the running system does not match the reviewed, version-controlled…

What you'll learn

Steps in this lab

  1. The words first: Terraform, state, provider, resource, drift
  2. Install Terraform and confirm it runs
  3. Write a tiny configuration that manages one local file
  4. Initialize and apply: create the file, record it in state
  5. Introduce drift on purpose: change the file by hand
  6. Detect the drift: terraform plan and the refresh step
  7. See drift alone with -refresh-only (detect without proposing changes)
  8. Reconcile, path A — world is truth: apply -refresh-only
  9. Reconcile, path B — code is truth: apply to heal the drift
  10. Judgment: when each reconciliation is right — and when NOT to

Open the full interactive lab →