Full lesson
Explore the full explanation, examples, and visuals at your own pace.
Terraform state records what it manages and which real objects match.
Terraform state is a record of managed objects and their real counterparts, helping plan later VM changes.
After apply: web has a real VM
After the provider creates the VM for web, Terraform records its resource address, provider-assigned ID, and known attributes in state. That mapping lets Terraform identify this same VM later.
A later plan checks the VM
When web’s requested size changes, Terraform looks up its recorded ID in state, then asks the provider for the VM’s current details. It compares those details with the configuration to plan a change. State helps locate the object, but it isn’t a live or infallible inventory.
If the requested size of web changes, how does Terraform find the existing VM to check?
Let's think this through. If the requested size of web changes, how does Terraform find the existing VM to check? A: It uses the VM ID recorded in state. B: It creates a new VM before checking. C: It searches for any VM named web. Choose an answer, or just think it through. I'll explain in a moment.
- It uses the VM ID recorded in state
- It creates a new VM before checking
- It searches for any VM named web
If the requested size of web changes, how does Terraform find the existing VM to check?
The answer is A: It uses the VM ID recorded in state. State links the resource called web to the provider-assigned VM ID. Terraform can use that link to ask the provider for current details before deciding what change to plan. The configuration name alone is not a reliable way to identify the real VM.
- It uses the VM ID recorded in state
- It creates a new VM before checking
- It searches for any VM named web
Why protect state?
Protect state because losing it can leave Terraform unsure which real VM belongs to web. State may contain sensitive values, so teams use protected shared storage and locking to coordinate changes.
- Losing it breaks the resource mapping
- It may contain sensitive values
- Teams need a shared, protected copy
The link makes the next plan possible
State records Terraform's known mapping and attributes; configuration expresses the desired result. For web, the recorded VM ID lets Terraform check that object and plan the requested size change.

