Terraform State

Terraform State is a metadata used by #HashiCorp Terraform to track the status of the real world infrastructure. It is usually stored as a JSON file with the file name terraform.tfstate. Every time we hit terraform plan or terraform apply, we’ll refresh the state. In order to not do so, we can perform terraform plan --refresh=false so that Terraform will deploy the server referring to the file terraform.tfstate and do not refresh it.

It is advised to let everyone having the latest state of the Terraform State (the file terraform.tfstate should be the latest), no simultaneous access to Terraform operations especially those that can change state and be private. One solution to this is to store the state remotely, such as in AWS S3, Google Cloud Service, HashiCorp Consul and Terraform Cloud.

#devops