PREP WITH PROOF
Menu
TERRAFORM / PRACTICAL GUIDE

A Terraform Plan Review Routine for Risky Changes

Review Terraform replacements, deletions, permissions and unknown values before apply. Includes a saved-plan workflow and tested JSON action triage.

THE QUICK ANSWER

Review a Terraform plan against the intended change, target environment and exact saved artifact. Prioritize destructive actions, replacements, access changes and unresolved values. A successful plan is evidence of proposed operations, not proof of availability, authorization or a safe recovery path.

Start with the change you intended to make

A pull request says “adjust a service label,” but the plan contains a replacement and a permission update. The review question is not whether Terraform finished successfully. It is whether the proposed operations match the approved intent, and whether their consequences are understood in the target environment.

Write a short expected-change statement before reading the plan. Name the affected component, expected action and things that must remain stable. A useful example is “update the application label without replacing the database or changing its access policy.” This gives the reviewer a concrete comparison instead of asking them to approve a large diff by intuition.

This guide expands the earlier short review note into a practical workflow. The Python triage example was tested against synthetic plan-shaped JSON. Terraform and provider operations were not run in the editorial environment; commands and field meanings were checked against current HashiCorp documentation. No example represents an observed production incident.

Verify the target and inputs before judging the diff

Confirm the working directory, backend, selected workspace, cloud account or subscription, region and variable inputs. A familiar resource name is not sufficient evidence that a plan targets the intended environment. Record the source revision and provider selections so another reviewer can identify which inputs produced the artifact.

Use the project’s normal initialization and validation process before planning. Validation checks configuration structure and consistency; it does not establish that a real deployment will meet availability requirements. Keep provider upgrades separate from an unrelated infrastructure edit where possible, since combining them makes unexpected changes harder to attribute.

Inspect the command flags. A targeted or non-refreshing plan has a narrower interpretation than an ordinary complete plan. Do not quietly use targeting, disable refresh or bypass a state lock merely to make the output easier to approve. If the workflow requires an exception, state what evidence is omitted and why that exception is justified.

Source: HashiCorp: terraform validate ↗

Capture one reviewable artifact and preserve exit-code meaning

In an initialized, authorized workspace, save a plan and render that same saved artifact for review. The shell fragment below handles detailed exit codes explicitly: zero means no changes, two means a successful plan with changes, and an error must stop the workflow. Treating every nonzero result as an infrastructure failure incorrectly rejects a valid changed plan.

The umask restricts newly created artifact permissions in this shell session; it does not replace encrypted storage, access control or artifact-retention policy. Saved plans and their JSON representation can contain sensitive data. Do not attach unreviewed artifacts to public issues or print full JSON into broadly accessible CI logs.

Use the human-readable rendering to explain the change and the JSON representation for structured checks. terraform plan -json is a stream of machine-readable UI events, not the same artifact format as terraform show -json applied to a saved plan. Select the right input contract before writing a parser.

# Use only in the intended, initialized workspace.
set -eu
umask 077
plan_status=0
terraform plan -input=false -detailed-exitcode -out=review.tfplan \
  || plan_status=$?
case "$plan_status" in
  0|2) ;;
  *) exit "$plan_status" ;;
esac
terraform show -no-color review.tfplan > review.txt
terraform show -json review.tfplan > review.json

Source: HashiCorp: terraform plan ↗

Review consequences before counting actions

Begin with deletions and replacements. Identify the resource, what makes replacement necessary, whether data survives and what depends on its identity. A change can replace an object even when the original request only edited one attribute. Trace the replacement back to its cause rather than judging risk from the size of the textual edit.

Then inspect updates to permissions, network access, encryption, retention and identity. An in-place update can create a larger exposure than a new stateless component. Require a concrete explanation of the before-and-after access boundary and the expected consumer of the change.

Review creations for dependencies, quotas and naming collisions. A create-before-destroy sequence may require both objects to coexist and does not automatically preserve application traffic. Resource count alone cannot establish capacity, recovery time or data safety. Use the plan to ask the service-specific questions that Terraform cannot answer for you.

Plan evidenceReview question
DeleteIs removal intended, and what data or dependencies disappear?
Delete then create / create then deleteWhy replacement, and how does the service transition?
In-place updateCan access, durability or application behavior change?
Unknown after-valueWhich decision depends on a value not yet known?
Output changeDoes a downstream consumer receive a different contract?

Use JSON to find review items, not to approve the plan

In resource_changes, inspect each change.actions array. Both delete/create orders represent replacement sequences, while update deserves its own review. The replace_paths field can help identify attributes that caused a replacement, but it may be absent, including when replacement is requested for another reason. Do not require its presence before recognizing replacement.

The function below returns addresses and action categories without printing before/after attribute values. It skips data-source entries and no-op managed entries, because its purpose is managed-resource action triage. It deliberately does not inspect output changes, drift, checks, access-policy contents or apply-time behavior. An empty result is not approval.

The compact fixture is handcrafted JSON with only the fields this helper consumes, not a complete exported Terraform plan. The synthetic example_service address does not identify a real provider resource. Save the Python as review_actions.py if using the optional file-loading lines, and feed it a controlled copy of show -json output.

import json
import sys


def review_actions(plan):
    if plan.get("format_version", "").split(".")[0] != "1":
        raise ValueError("Unsupported plan JSON format major version")
    rows = []
    for resource in plan.get("resource_changes", []):
        if resource.get("mode") != "managed":
            continue
        actions = tuple(resource["change"]["actions"])
        if actions == ("no-op",):
            continue
        if actions in (("delete", "create"), ("create", "delete")):
            category = "replacement"
        else:
            category = {
                ("delete",): "delete",
                ("create",): "create",
                ("update",): "update",
            }.get(actions, "unrecognized-review-required")
        rows.append({"address": resource["address"],
                     "category": category, "actions": list(actions)})
    return rows


fixture = {"format_version": "1.2", "resource_changes": [
    {"address": "example_service.main", "mode": "managed",
     "change": {"actions": ["delete", "create"]}}
]}
assert review_actions(fixture)[0]["category"] == "replacement"

if __name__ == "__main__" and len(sys.argv) == 2:
    with open(sys.argv[1], encoding="utf-8") as source:
        print(json.dumps(review_actions(json.load(source)), indent=2))

Source: HashiCorp: JSON output format ↗

Distinguish unknown, null and sensitive values

The after object does not always contain a fully known final value. Consult after_unknown when determining which fields remain unresolved. A missing or null-looking value in a simplified extraction is not enough to conclude that a field will be cleared. Preserve the distinction between an actual null and a value Terraform cannot yet know.

Sensitivity markers describe which values should be protected in a user interface; they are not evidence that the exported JSON has removed those values. HashiCorp warns that show -json can expose sensitive values in plain text. Even resource addresses or keys can reveal operational details, so the helper’s short output still needs an appropriate audience.

If an important permission, endpoint or identifier is unknown, document how it will be verified and what stops an unsafe result from reaching users. Do not convert uncertainty into a default “safe” classification simply because a policy script cannot inspect the final value.

Source: HashiCorp: terraform show and sensitive JSON ↗

Understand the limits of lifecycle protections

prevent_destroy can reject a plan that destroys a protected object while the rule remains in its configuration. It does not provide a universal guard against deleting that object after its resource configuration is removed. Check the configuration boundary as well as the plan action.

create_before_destroy changes ordering for replacement and can propagate through dependencies. Review coexistence requirements and provider constraints instead of assuming the flag guarantees zero downtime. Application cutover, DNS, connections and data migration may still require an explicit service plan.

ignore_changes intentionally stops selected remote changes from being reconciled by ordinary updates. It can support shared ownership, but it can also hide a difference you expected the plan to surface. Record which system owns each ignored field and how that ownership is checked outside this plan review.

Source: HashiCorp: lifecycle meta-arguments ↗

Bind the decision to the artifact and recheck changed assumptions

A review record should name the source revision, target, saved-plan artifact identity, unexpected operations investigated and the evidence supporting the decision. If the workflow later applies a saved plan, use the exact approved artifact through the authorized deployment process. Running apply without a saved plan creates a new planning decision rather than reusing the reviewed proposal.

Saved-plan application does not offer the same interactive approval pause as ordinary automatic planning. Access to that artifact and permission to run the deployment therefore matter. Keep approval enforcement in the surrounding workflow and do not mistake a filename for proof that the right reviewer approved the right bytes.

Replan and review when inputs, intended target or important assumptions change. A plan is not a reservation of cloud capacity and cannot guarantee that provider calls will succeed. State changes can make an old saved artifact unusable, and unrelated operational changes can invalidate the reasoning even before an apply is attempted.

The useful outcome is an explainable decision: which operations are intended, which risks were investigated and which unknowns remain. Automate the repetitive extraction, keep the decision tied to evidence and inspect the service behavior after an authorized deployment. A green plan command alone answers only a small part of that review.

Source: HashiCorp: applying a saved plan ↗

KEEP THESE THREE THINGS

Your next steps

  1. Confirm the exact target and inputs, then compare the plan with a written expected-change statement.
  2. Review replacements, deletions, permissions and unknown values; use JSON triage as an aid rather than an approval engine.
  3. Protect saved artifacts and bind approval to the exact reviewed plan; revisit the decision when assumptions change.

Sources & official resources

Linked resources checked on 2026-10-25. Technical behavior and provider guidance can change; check the documentation for the version you use.

About this guide and its recommendations

Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.

Suggest a correction →