Interview Prep/Terraform/State Internals

What is state locking and why does it matter?

IntermediateConceptState Internals
Answer

When a command that can write state starts, Terraform takes a lock so two runs cannot modify the same state concurrently, which would corrupt it or create duplicate resources. A second run fails with Error acquiring the state lock and shows who holds it. Local state locks via a file, remote backends via their own mechanism.

All Terraform questions Roadmap: Terraform in production

More on State Internals