grafclouds.com / documents / training / devops-challenges / terraform-state-drift

Someone Changed Infra by Hand. Terraform Plan Is a Mess.

Intermediate ~12 min read
Terraform

Scenario

During a recent incident, an engineer went straight into the cloud console and adjusted things by hand — a couple of load balancer settings, some security group rules — to get the fire out. It worked, but nothing was written down and nothing went through version control. Days later, someone runs terraform plan and gets a wall of unexpected diffs: Terraform wants to revert settings on the load balancer and the security group back to what the code says. Nobody is sure which of the manual changes were the real fix and which were temporary experiments that should never survive. State and reality have parted ways, and every apply is now a loaded gun.

The Quick Fix on the Table

Two competing shortcuts get proposed in the same meeting. One camp says "just run terraform apply — the code is the source of truth, whatever it reverts obviously wasn't official." The other says "just run terraform refresh or update the code to match whatever is live — reality wins, the incident fix must be preserved." Both are one-command solutions, and both are wrong as blanket policies.

Interview · Round 1

The quick fix is on the table and the room is waiting for your call. Would you sign off on it? Take a position and justify it — out loud or on paper — before revealing the analysis.