Terraform Plan
The terraform plan command previews what Terraform would create, change, or destroy, without changing anything. It compares your configuration, the state file, and real infrastructure, then prints the differences.
What Is Terraform Plan?
Plan is the read-only review step before every change.
Bash
terraform plan -out=tfplan.binary # save for applyterraform show -json tfplan.binary > plan.json # for cost and policy toolsterraform plan -detailed-exitcode # 0 no changes, 1 error, 2 changes| Symbol | Meaning |
|---|---|
+ |
Create |
~ |
Update in place |
-/+ |
Destroy then create |
- |
Destroy |
A value shown as (known after apply) is not known until the resource exists.
Common MistakeApproving a
-/+on a database without reading what forces the replacement.
Frequently Asked Questions
Does terraform plan change anything?
No. It is read-only, though it refreshes state by reading provider APIs. It only writes a plan file if you pass -out.
Why save the plan with -out?
It guarantees the reviewed actions are the ones executed, since a fresh plan at apply time can differ.
Found a mistake, an outdated step or a broken link?