What is the Terraform state file and why does it exist?
BeginnerConceptIaC and Terraform Fundamentals
Answer
State (terraform.tfstate) is a JSON file mapping each resource in your config to the real object ID in the cloud, plus attributes and metadata. Terraform needs it to know what it already manages, to compute diffs, to order destroys and to avoid slow lookups of everything on every plan. Without state, Terraform cannot tell a resource it created from one that already existed.
More on IaC and Terraform Fundamentals
What is Infrastructure as Code and why do teams use it?BeginnerWhat is the difference between declarative and imperative infrastructure tools?BeginnerWhat is Terraform and what problem does it solve?BeginnerWhat is HCL and can Terraform use anything else?BeginnerWhich files make up a typical Terraform root module?BeginnerHow does Terraform work internally?Advanced