The Terraform state file (terraform.tfstate) is a JSON record that maps the resources in your configuration to the real objects Terraform manages. Terraform uses it to work out what has changed, what to create and what to destroy on the next plan.
Teams store state in a remote backend, such as Amazon S3, Azure Storage, Google Cloud Storage or HCP Terraform, with locking so two runs can’t change it at once. Local state files don’t work for teams.
State can contain sensitive values, such as database passwords, in plain text. Encrypt the backend, restrict access and never commit .tfstate files to Git.
State files don’t belong in Git. Add *.tfstate and *.tfstate.* to .gitignore and use a remote backend with locking and encryption.