The tiny Terraform wrapper that made rollbacks predictable

After a midnight Terraform mistake, I built a tiny wrapper that checkpoints state and plans, so rolling back infra stops being a guessing game — and what it still can't save.

Written by: Arjun Malhotra

Open laptop with code editor on screen and a coffee cup
Photo by Brooke Cagle on Unsplash

It was 2:10 a.m. I had accepted a small, urgent change: flip a flag and increase the autoscaling target. The person handing it over said “terraform apply, should be fine.” The plan showed drift on one resource — a storage bucket with a lifecycle rule — but nothing alarming. I hit apply. Five minutes later, an entire test dataset was gone and my pager wouldn’t stop.

That night I learned two things: one, never trust an “urgent” apply without a checkpoint. Two, Terraform’s state is both your friend and the source of peril. I built a tiny wrapper in the week after that incident. It doesn’t make Terraform magic, but it makes rollbacks predictable enough that I stopped waking up with a knot in my stomach.

What the wrapper does, in one sentence

Why this matters in practice

How it works (the useful bits)

Why I use an object store with versioning

One scripted example, pared down

Where it actually saved us

The honest failure and the tradeoffs

Small operational notes that saved me grief

Costs and constraints — India specifics

What I actually walked away with

If you take anything from this, it’s simple: treat “state before change” as an artifact worth preserving. You won’t always be able to restore data, but you’ll always reduce the guesswork.