Preview changes Terraform will make to infrastructure.
low risk
terraform plan compares desired state (HCL) with current state (tfstate) and shows exactly what will be created, changed, or destroyed. Always run before apply — the plan output is your contract for what will happen in production.
| Flag | Meaning |
|---|---|
-out | Save plan to a file for later apply |
-var | Set a variable value |
-var-file | Load variables from file |
-target | Plan only specific resources |
-destroy | Plan a destroy operation |
terraform plan -out=tfplanSave plan for deterministic apply · explain & risk-check →terraform plan -var-file=production.tfvarsPlan with production variable file · explain & risk-check →terraform plan -target=aws_instance.webPlan only a specific resource · explain & risk-check →terraform plan -destroyPreview a full destruction · explain & risk-check →In CI/CD, always use `terraform plan -out=tfplan` then `terraform apply tfplan` — the saved plan ensures apply executes exactly what was reviewed, preventing drift between plan and apply.
Reference text is hand-written and may be incomplete — check man terraform for your version. Test destructive commands on a non-production system first.