Terraform must store state about your managed infrastructure and configuration. This state is used by Terraform to map real world resources to your configuration, keep track of metadata, and to improve performance for large infrastructures.
---
# Purpose of Terraform State
State is a necessary requirement for Terraform to function. It is often
asked if it is possible for Terraform to work without state, or for Terraform
to not use state and just inspect cloud resources on every run. This page
will help explain why Terraform state is required.
As you'll see from the reasons below, state is required. And in the scenarios
where Terraform may be able to get away without state, doing so would require
shifting massive amounts of complexity from one place (state) to another place
(the replacement concept).
## Mapping to the Real World
Terraform requires some sort of database to map Terraform config to the real
world. When you have a resource `resource "aws_instance" "foo"` in your
configuration, Terraform uses this map to know that instance `i-abcd1234`
is that resource.
For some providers like AWS, Terraform could theoretically use something like
AWS tags. Early prototypes of Terraform actually had no state files and used
this method. However, we quickly ran into problems. The first major issue was
a simple one: not all resources support tags, and not all cloud providers
support tags.
Therefore, for mapping configuration to resources in the real world,
Terraform requires states.
## Metadata
Terraform needs to store more than just resource mappings. Terraform
must keep track of metadata such as dependencies.
Terraform typically uses the configuration to determine dependency order.
However, when you delete a resource from a Terraform configuration, Terraform