Plan actions and review
A plan is a proposal, not a deployment
A Terraform plan describes intended operations after comparing configuration, recorded bindings and provider observations. For example, changing a local catalog label from catalog-v1 to catalog-v2 may require an update, while introducing a new address may require creation. Read the proposal before allowing changes. Planning can access backends, read external data, execute provider code or initiate a remote run; it is not a universally harmless dry run. The following exercises use only a fresh local directory and the built-in provider.
Recognize the proposed actions
Read this invented summary; the example_service and example_catalog names are fictional, not installable providers.
Fictional review summary (not CLI output)+ terraform_data.new_item~ terraform_data.catalog- terraform_data.retired-/+ terraform_data.release+/- example_service.blue<= data.example_catalog.currentA plus means creation, a tilde an in-place update and a minus deletion. A replacement combines deletion and creation: the order distinguishes destroy-first from create-first. The read marker denotes a data-source read deferred to apply. An unchanged resource may have a no-op action in the machine-readable plan, even when it is not shown in the ordinary diff. A moved address can also appear without resource replacement. Check the full details, not just totals. For replacement, examine availability, dependencies, uniqueness constraints, cost and data preservation; creating first does not guarantee uninterrupted service.
Observe a local update
Use the catalog fixture in a disposable copy. The version constraint is inherited and unverified here.
variable "label" { type = string default = "catalog-v1"}
resource "terraform_data" "catalog" { input = var.label}
output "label" { value = terraform_data.catalog.output}After successful initialization, the first normal plan should propose creation. With explicit approval, apply and inspect the output. A second plan with unchanged input should have no changes. Then plan with a different value, which is expected to update the existing local resource. The output follows the updated value after applying.
terraform plan -var="label=catalog-v2"Do not confuse a value unknown until apply with a null value or a redacted sensitive value. A generated ID can be unknown before creation; redaction does not imply absence from the plan file.
Choose the planning mode deliberately
A normal plan proposes convergence toward configuration. Refresh-only mode proposes reconciling recorded state and root outputs with observed changes, not restoring configuration by modifying managed objects. Applying a refresh-only plan can still change state. Destroy mode proposes removal of managed objects in scope; it is not a way to clear a display. Use these commands for inspection only in the local catalog fixture after a successful initial apply.
terraform plan -refresh-onlyterraform plan -destroyReview the selected backend and workspace even when the command only plans. The modes are mutually exclusive. In the local example there is no remote drift to observe; refresh-only may report no changes.
Interpret detailed exit codes
For POSIX shells the following example captures the status immediately. Run only in the initialized local fixture.
terraform plan -detailed-exitcodestatus=$?case "$status" in 0) printf "%s\n" "No changes" ;; 1) printf "%s\n" "Planning failed" ;; 2) printf "%s\n" "Changes require review" ;; *) printf "%s\n" "Unexpected status; stop" ;;esacWith this option, zero means success with no diff, one means error, and two means success with changes. A wrapper that treats every nonzero code as a failure misclassifies code two. Under shell errexit settings, capture nonzero status in a conditional instead. None of these codes is approval to apply.
Review the impact before approval
Start with the exact working directory, version, backend, workspace and intended identity. Check affected addresses, replacement order, deletion risk, unknown and sensitive values, provider and module changes, expected costs and independent backup or rollback requirements. Escalate unexpected scope instead of targeting individual resources to hide it. Complete the plan-classification worksheet before proceeding.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Plan actions and review — knowledge check
Review proposed changes and saved-plan approval.
What does an in-place update marker normally indicate?
What does a delete-then-create replacement imply?
Which mode proposes recording observed drift without changing managed objects?
With -detailed-exitcode, what does 2 mean?
Which statement about a plan is correct?