Review and apply a saved plan
Create a plan, inspect it later without contacting providers, and apply exactly that saved whole-app artifact. This walkthrough extends the local hybrid app and needs no cloud account.
Before you start: keep that tutorial's app.py, Random bindings and [tool.nf] entry.
Keep the same Python environment active.
Use a project with its Random resource destroyed if you want to see a create in the plan;
otherwise an unchanged resource correctly produces a no-op plan.
1. Save a plan
nf plan --app app --out .nf.out/reviewed-plan.json
Read the summary and resource changes. For the original example, a fresh state has a create
for names.random_pet.example. The exact generated name is unknown until apply.
This artifact represents one app. A stack-specific direct plan cannot be applied through
--plan-file; choose the app boundary you intend to review.
2. Inspect the saved artifact
nf show --plan-file .nf.out/reviewed-plan.json
show reads the saved plan; it does not replan or require provider credentials. Check the
app, actions, imports, replacements, runtime checks and any deferred changes before deciding
whether the change is acceptable. A plan that only imports existing objects still changes
state ownership and deserves that review.
3. Apply after review
nf apply --app app --plan-file .nf.out/reviewed-plan.json
Approve the prompt. The app must use the same state/backend and compatible provider settings as the plan. If nf reports that the plan is stale, generate a new plan and review it rather than editing the artifact or overriding the state.
4. Check the result
nf plan --app app
For this example, expect no resource changes. When finished, clean up with the same app and backend:
nf destroy --app app
Next: environment promotion, CI/CD, or adoption.
What a saved plan preserves
The artifact carries the reviewed execution changes, prior/desired state, provider and state fingerprints, and the information needed for imports and runtime checks. It is an execution artifact, not an alternative source file to maintain by hand.
nf validates fingerprints before apply. A resource's live state can also have changed since review; saved plans are not a reservation on cloud objects. Keep review and execution close and inspect errors instead of assuming an old plan can always be replayed.
Adapt this procedure for CI
Split planning and applying into separate jobs when your review process needs it:
- Check out the intended code revision, install its locked dependencies, and generate any provider packages the project expects.
- Select the destination environment and backend, plan, and retain the plan artifact with its code revision and review record.
- Download that same artifact in the approved apply job and use
--plan-file. - Retain the result and run a fresh plan to verify convergence.
The tutorial uses a local backend in one project. Jobs on different runners need the same shared backend, not unrelated local state files with matching filenames. Regenerating a plan inside the apply job produces a different change set and needs its own review.
An authorized unattended apply can use --auto-approve. Imports still need
--approve-imports; deferred rounds have --apply-deferred and a separate approval policy.
See adoption and
deferred provider configuration.
Retain artifacts with appropriate access
Saved plans, state and checkpoints can contain sensitive values even when terminal summaries
mask them. Store them with the same access controls as state. For a failed apply, preserve
its recovery notes and any errored.tfstate; follow the recovery runbook
before retrying.