Read a destroy (-)
Learn
Reading a destroy
Remove a resource from your code, and Terraform plans to remove it from the world too:
# demo_server.web will be destroyed
- resource "demo_server" "web" {
- name = "web"
- image = "base"
- cpu = 1
- id = "demo_server-977a3db6"
- private_ip = "10.0.151.122"
}
Plan: 0 to add, 0 to change, 1 to destroy.
The server is still in state but no longer in your code, and Terraform's job is
to make the world match the code. Notice the attributes now show real values, not
(known after apply): this is a real resource, and the plan lists everything that
will be lost with it.
The cpu edit from the last step is gone too, because you deleted that whole block.
The habit: you always
planbefore youapply. The plan is a read-only preview with no side effects, so it's where you catch mistakes while they're still free to fix.
Your task
Delete the entire demo_server "web" block from your config (keep the network), then run plan. The server is still in state but no longer in your code, so Terraform plans to destroy it: a red - and Plan: 0 to add, 0 to change, 1 to destroy. Then answer the questions below.
Your answers are checked when you run this step.
Interview prep
“Walk me through a terraform plan” is one of the most common screening questions — be able to read every symbol cold.
What do +, ~, and -/+ mean in a terraform plan?
+ creates a new resource, ~ updates one in place, - destroys one, and -/+ (Terraform also prints “forces replacement”) means an immutable attribute changed so the resource must be destroyed and recreated. The summary line — “Plan: N to add, N to change, N to destroy” — is the headline you read before every apply.
Why run plan before apply at all?
plan is a read-only preview: it shows exactly what apply would add, change, or destroy, with no side effects. You read it to catch surprises — especially destroys and replacements — before they touch real infrastructure. On a team you also save the plan and apply that exact file, so what was reviewed is what runs.