Bits

Terraform State

Terraform’s state file is a snapshot of what Terraform believes the infrastructure looks like. It is not the infrastructure itself. That gap is where most of the tool’s pain lives. The criticisms are well known, and I share most of them.

The remedies are the usual ones. Use a remote backend with locking. Encrypt at rest and keep secrets out of state. Use ignore_changes and data sources to shrink what is tracked. Use workspaces per environment, and small modules with separate states. They work, and they all add machinery.

My view is that the state file is a symptom rather than a design flaw. Terraform needs it because the platforms it manages keep no versioned record of their own configuration. A platform that does, as Kubernetes does, moves the state store inside the platform rather than removing it. It keeps the same drift and reconciliation concerns. That is the narrower argument in The Problem with Infrastructure-as-Code.

All entries | Español