I am a little bit puzzled on the question whether to commit .tfstate
files to Git or not. The Terraform documentation states:
Terraform also put some state into the
terraform.tfstate
file by default. This state file is extremely important; it maps various resource metadata to actual resource IDs so that Terraform knows what it is managing. This file must be saved and distributed to anyone who might run Terraform. We recommend simply putting it into version control, since it generally isn't too large.
Now, on the other hand, the accepted and upvoted answer on Best practices when using Terraform states:
Terraform config can be used to provision many boxes on different infrastructure, each of which could have a different state. As it can also be run by multiple people this state should be in a centralised location (like S3) but not git.
(Emphasis by the original author, not by me)
Who is right, and if so, why?