State Introduction
We will learn Terraform state, state file, why you need a state, and how you can speed up the Terraform project.
We'll cover the following...
State
The state is Terraform’s store of all of the resources it has created. State stores all of the information about the resources, including meta-information, that cannot be retrieved from APIs’ underlying infrastructure. It also stores the dependency order of the resources that it created.
Terraform uses its state to work out how it needs to make changes. By default, Terraform stores the state in a local file called terraform.tfstate
. You may have noticed this file in the examples we have been doing up until now.
Why Terraform needs to record the resources
A common question is why Terraform needs to record the resources it has created in a state file? Why can’t it just look at the HCL code, compare that to the real world, and apply the changes? Well, there are ...