← Lessons/State — Break It & Recover
← State — Break It & Recover

Cause drift

Learn

Drift

Drift is the real world changing without Terraform: someone resizes a server in the cloud console, a script tags a bucket, an autoscaler adjusts a setting. Terraform didn't make the change, so state doesn't know about it.

plan finds it, because it refreshes before it diffs:

Note: Objects have changed outside of Terraform

  # demo_server.web has changed outside of Terraform
      ~ cpu = 2 -> 8

Terraform will perform the following actions:

  # demo_server.web will be updated in-place
  ~ resource "demo_server" "web" {
      ~ cpu = 8 -> 2
    }

Read it in two halves. The note is what changed in the real world (2 -> 8). The plan is what Terraform will do about it: put it back to what your code says (8 -> 2).

Someone bumps the server's CPU in the cloud console. Use Edit in console (it defaults to demo_server.web · cpu = 8) to change Real Infrastructure behind Terraform's back, then run plan. Terraform refreshes, sees reality no longer matches state, and reports drift. Then answer the questions below.

What is drift?
How did plan notice the console change?

Your answers are checked when you run this step.

Loading...

State Inspector

State

Terraform's memory

empty — nothing here yet

Real Infrastructure

the actual world

empty — nothing here yet

Break it & recover

These act outside Terraform — exactly how state gets into trouble in real life.

=