supraj.dev
Terraform

Remote state and locking

How do two people run Terraform on the same cloud without overwriting each other’s work?

28 s loop7 sentencesSilent, read alongScene: Orbit
Read the story, sentence by sentence 7 sentences

What you'll be able to say

  1. By default Terraform stores state in a local terraform.tfstate file; a remote backend such as gcs or s3 keeps one shared copy for the team.
  2. When the backend supports it, Terraform locks state automatically for every operation that could write it, so concurrent runs cannot corrupt it.
  3. A second run during a lock fails with a lock error; -lock-timeout makes it retry, and terraform force-unlock clears a stuck lock.