terraform plan

Preview changes Terraform will make to infrastructure.

low risk

interactive breakdown — edit the command and press Explain
$ 
What it does

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.

Common flags
FlagMeaning
-outSave plan to a file for later apply
-varSet a variable value
-var-fileLoad variables from file
-targetPlan only specific resources
-destroyPlan a destroy operation
Examples
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 →
Pro tip

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.

Related
terraform init terraform apply yq
Open the full explainer →More in Terraform, Ansible & IaC

Reference text is hand-written and may be incomplete — check man terraform for your version. Test destructive commands on a non-production system first.