Skip to content
Preptima
hardConceptDesignMidSeniorStaff

Why is state the hard part of Terraform, and how do you manage drift, imports and locking around it?

6 min readUpdated 2026-08-15

Answer

Short answer

State is the mapping from a config address to a real resource ID, so it is the only thing that tells Terraform whether to create or update. Drift, imports, refactors and concurrent applies are all consequences of that mapping being separate from both the code and the infrastructure.

Mention iac where it changes the risk, the owner, or the next check. A useful iac point should make the answer more testable, not merely longer.

Was this answer helpful?

Likely follow-ups

  • Someone ran an apply from a laptop while CI was mid-apply and the lock was released by hand. What do you do now?
  • You need to move three resources out of a monolithic state into a new one without any downtime. How?
  • A plan wants to replace a resource because of a change to an attribute the provider marks as forcing replacement. What are your options?
  • When would you deliberately not use a module, and what does a module that wraps a single resource cost you?

Related questions

Masterclass guide

Further reading

Related Topics