Question 1 · choose 1
An engineer suggests that Terraform could skip state entirely and find its resources by tags on every run. Why does Terraform keep state instead?
- AIt needs a binding for each resource instance, and many resources cannot be tagged
- BTags are read-only for providers, so Terraform cannot set them on the resources it creates
- CState is only a performance cache, and Terraform could work without it at the cost of speed
- DState stores the configuration, so Terraform can run without the .tf files
Show the answer and why
AIt needs a binding for each resource instance, and many resources cannot be tagged
Correct
State maps configuration to real objects, such as an instance ID; tags were tried early on and failed because not all resources support them.
BTags are read-only for providers, so Terraform cannot set them on the resources it creates
Incorrect
Providers can usually set tags; the problem is that many resource types have none.
CState is only a performance cache, and Terraform could work without it at the cost of speed
Incorrect
Caching is the most optional part of state. The mapping and metadata make state a requirement.
DState stores the configuration, so Terraform can run without the .tf files
Incorrect
State does not replace configuration; it records what the configuration manages.
State is required: it is the database of bindings between configuration and the real world, plus metadata that configuration alone cannot carry.
HashiCorp documentation