Commit terraform.tfstate to the Repo So Everyone Shares It?
A teammate wants to commit terraform.tfstate to git so the whole team shares one state file. Defend the correct way to share Terraform state.
Your decision
Two engineers ran terraform apply from their laptops and got conflicting results. A teammate proposes committing terraform.tfstate to the git repo so everyone shares the same state. Do you agree, and what do you do instead?
The situation
Your team manages infrastructure with Terraform. Two engineers ran terraform apply from their own laptops against the same environment and ended up with divergent state and a resource that exists in the cloud but not in either local state file. Applies are now producing confusing plans that want to create things that already exist.
Context
Each engineer has their own local terraform.tfstate on disk. There is no shared backend configured. The Terraform configuration provisions an RDS database, so the state includes the generated master password in plaintext. A teammate suggests committing terraform.tfstate to the git repository so everyone pulls the same state before running apply.