AceReady
Terraform
Question 1 of 13
Easy

What is Terraform's state file for ?

Answer

The state file keeps the mapping between resources declared in the Terraform configuration and the real resources already created at the cloud provider, along with their identifiers and current attributes. It's by comparing this recorded state with the desired configuration that Terraform determines which actions to take, create, modify or delete, to converge the real infrastructure toward what's described in the code. Without this file, Terraform would have no way of knowing which resources already exist or of linking a resource declared in code to its real counterpart at the provider.

Common trap

The trap is modifying a Terraform-managed resource directly in the cloud provider's console, outside of Terraform: the state file no longer reflects reality, what's called configuration drift, and the next Terraform plan can then propose undoing that manual change without that being the intent.