Member-only story
Terraform Basics — State
Note, full mind map is available at: “DevOps in Terraform MindMap”
Terraform State
State is a fundamental requirement for Terraform to function properly. It is used to store vital information about your managed infrastructure and configuration. Terraform relies on the state to map resources to your configuration, keep track of metadata, and improve performance, especially for large infrastructures.
When you run terraform apply
, Terraform checks the current state and compares it with your configuration files. It then determines what changes need to be made to the actual infrastructure to match your configuration.
By default, Terraform stores the state in a local file called terraform.tfstate
. However, it also provides the option to store state remotely, which is particularly useful in team environments. We briefly discussed this in the previous lesson on backend configuration.
How Does State File Work?
Terraform uses the state file to keep track of the IDs of created resources so that it can make…