Skip to content

nf apply

Apply changes to a configured app. Use --plan-file to apply a saved whole-app plan. For Terraform/OpenTofu compatibility, pass a synthesized stack directory to --stack.

Synopsis

nf apply [OPTIONS] [TERRAFORM_ARGS]...

Main Modes

App-Scoped Direct Apply

nf apply --app demo --plan-file reviewed-plan.json

This applies the plan saved by nf plan --app demo --out reviewed-plan.json. nf apply --app demo without a plan file creates a fresh plan and prompts for approval.

A direct apply runs as a Pulumi update does:

  • it names the app and its state backend first
  • the approval shows the changes as nf plan does (the tree, then Resources:). Answering details shows each change's attributes (sensitive values masked) and asks again; only yes applies. Declining reports the apply as cancelled, with nothing changed
  • on a terminal, progress is drawn live: each resource's outcome as it finishes, above a footer of what is in flight with its elapsed time. Elsewhere (CI, a pipe, CI set or nf --non-interactive) it is one line per event. --quiet hides per-resource progress
  • the terminal is told what the run does, where it can show it while you are elsewhere (see Telling the terminal)
  • it ends with Resources: (what was created, updated, replaced or deleted, and what is unchanged), Duration:, the app's Outputs: (sensitive ones as [secret]) and, when it failed or was stopped, Diagnostics: grouped by resource

nf destroy --app and nf deploy --app show their runs the same way.

JSON output

--json (with --auto-approve: a run printing JSON cannot ask) prints the run as one document on stdout and nothing else; what nf would print otherwise, a Ctrl-C notice included, goes to stderr. Exit codes stay as they are: a failed run still prints its document, then exits 1.

{
  "format": "nf.run/1",
  "runs": [
    {
      "app": "demo", "stack": null, "operation": "apply",
      "success": true, "stopped": false, "cancelled": false, "complete": true,
      "duration_seconds": 4.2,
      "counts": {"create": 7, "replace": 1}, "unchanged": 34,
      "resources": [{"address": "compute.random_pet.host", "action": "replace", "status": "completed", "elapsed": 0.2, "error": null}],
      "outputs": {"compute.secret": "[secret]", "network.vpc": "immortal-asp"},
      "errors": [], "warnings": [], "deferred": [], "retained": [],
      "run_id": "20261120T120000.000000000Z-1a2b3c4d",
      "finalization": {"status": "finalized", "attempt": 1, "resumed": false, "problems": [], "evidence": [{"kind": "audit", "sha256": "…", "schema_version": "1"}], "record": "s3://state/app/nf.tfstate.runs/20261120T120000.000000000Z-1a2b3c4d.json"}
    }
  ]
}

--show-secrets shows sensitive outputs, in the summary and in the document, instead of [secret]. nf destroy --json writes the same document ("operation": "destroy", no outputs). finalization is there when the app has finalizers; retained lists what a destroy kept (Keeping resources).

Configured App Stack Direct Apply

nf apply --app platform --stack network

This runs the direct engine for one configured stack. Save and apply an app-level plan when you need to review the exact artifact in advance.

Legacy Stack Apply

nf apply --stack .nf.out/platform/network

With the explicit synthesized directory, Terraform or OpenTofu runs apply.

Options

  • --app TEXT: app selector for direct execution
  • --stack, -s TEXT: configured app/stack or synthesized legacy stack selector
  • --legacy-bin TEXT: path to the legacy CLI binary
  • --plan-file FILE: apply a saved whole-app direct plan selected by --app
  • --outdir PATH: synthesized output directory override
  • --auto-approve: skip interactive approval
  • --json: print the run as one JSON document (direct execution; needs --auto-approve)
  • --show-secrets: show sensitive outputs in the summary and the JSON document (not of imports: see --approve-imports)
  • --approve-imports: let --auto-approve approve the plan's imports of existing objects (default off; approve_imports in [tool.nf.config])
  • --adopt-from FILE, --terraform-state FILE, --adopt-missing, --allow-duplicate-adoption: as for nf plan
  • --recovery-strategy checkpoint|rollback|none: what a failed direct apply does (default checkpoint; see Rollback and Recovery)
  • --run-status/--no-run-status: keep the run's live status beside its state for nf follow (default on)

Global settings of nf (--max-concurrent-resources, --provider-apply-timeout, --graph-lease-ttl...) may be written after the command too. See Settings.

Direct execution controls

These controls apply to configured hybrid apps and directly executed legacy apps:

Option Behavior
--parallelism N Concurrent resource mutations; default 10 (nf --max-concurrent-resources for every command)
--read-parallelism N Concurrent refresh/plan calls and independent provider startup; default 40 (nf --max-concurrent-reads)
--refresh=false Plan using stored values without refreshing managed objects; default true
--target ADDRESS Select a full state address, such as platform.aws_vpc.main, plus its dependencies; repeatable
--plan-scope changed Inspect edited configurations and their dependency closure; full drift inspection is the default
--quiet Hide per-resource progress; keep the final result summary
--graph-plan-scope full\|affected Graph planning qualification policy; affected requires a retained baseline
--baseline FILE Retained graph branch origin (uses nf.baseline when present)
--prefer-mine ADDRESS Resolve a graph intent conflict using this branch's configuration; repeatable
--provenance-report Report observed reads, writes and estimated lease requirements

Changed scope and targets leave unrelated drift uninspected. Unknown evaluation effects make changed scope fall back to full configuration inspection. Existing rows without configuration fingerprints are inspected once. Saved plans preserve their scope; scope flags cannot alter --plan-file. --graph-plan-scope affected cannot be combined with these targets, changed scope or refresh=false. Stack selection uses --stack app/stack or --app app --stack stack.

Raw Terraform/OpenTofu arguments and --legacy-bin are rejected for hybrid apps. Synthesized legacy stacks retain their subprocess passthrough path.

Additional apply controls:

Option Default and behavior
--apply-deferred Off; allow saved/auto-approved plans to plan and apply deferred changes
--deferred-approval each_round\|once\|auto\|always each_round; each deferred round is shown and approved separately. auto requires --apply-deferred
--incomplete-exit-code N 4 when an otherwise successful apply leaves deferred changes
--provider-data-sources read\|state read; refresh provider-setting data sources before configuration
--deleted-objects review\|recreate\|error review; recreating externally deleted objects requires review
--concurrent-applies / --no-concurrent-applies Off; opt into graph resource grants with a retained baseline

See deferred provider configuration and graph state for approval and recovery behavior.

Important Behavior

  • direct apply supports app scope and configured app stack scope
  • legacy apply expects synthesized output to already exist
  • if you need raw Terraform/OpenTofu arguments or --legacy-bin, use the legacy --stack path instead of --app
  • explicit filesystem stack paths and synthesized stack selectors stay on the legacy subprocess path
  • stack directories that only contain legacy phased Terraform artifacts are rejected on the --stack path; use --app direct execution instead
  • nf deploy --app combines direct plan and apply. The legacy deploy path can run synthesis, external init, and external apply.
  • a whole-app plan deletes what state holds of stacks the app no longer declares, as Terraform deletes a removed module's resources: each resource after what depends on it, a retained one kept, and then the stack's data source results and outputs. It says so apart (Deletes the stacks the app no longer declares: web-prod (2), undeclared_stacks in --json), as a stack also vanishes when an input that names it is given otherwise (web-{env} applied with env=dev after env=prod). An auto-approved apply refuses it: review the plan and approve it, or apply it saved (nf plan --out FILE, then nf apply --plan-file FILE). A stack's apply (--stack) deletes no other stack

Interrupting

Ctrl-C works as it does for Terraform:

  • before anything changes (planning, the approval prompt) it aborts the command
  • once a direct apply changes infrastructure, the first Ctrl-C stops it cleanly: resources being applied finish and are recorded in state, nothing else starts, and the command exits 1 saying it stopped. The app's recovery_strategy applies as for any failed apply (see Stop an apply in progress)
  • a second Ctrl-C stops without waiting: changes in flight may not be recorded in state, so check them before the next apply (nf state recover for graph state). A third exits at once
  • on the legacy --stack path, Terraform/OpenTofu handles Ctrl-C itself (graceful, then immediate) and nf waits for it; a third Ctrl-C kills it

App Inputs

An app whose spec names a function takes its parameters as inputs: ++name=value anywhere on the line, or ++@file (TOML or JSON) for a file of them (nf apply --app web ++env=prod ++replicas=3). The header shows them (with env=prod replicas=3). With --plan-file, the app is built with the inputs the plan was made with; a value given that differs is refused, and secrets are given again. See nf vars.

Watching from Elsewhere

A direct apply keeps its live status beside its state (<state>.run.json; on a graph state backend, its operation rows say the same), so others can follow it as it goes: nf follow --app web (or nf tui follow) from another terminal or CI, or :runs in nf tui. It is written from a background thread and never fails the apply; nf apply --no-run-status, run_status = false in [tool.nf.config] or App(run_status=False) turns it off. See nf follow.

Telling the terminal

On a terminal (not with --json, nor in CI), nf plan, nf apply, nf destroy and nf deploy tell the terminal what they are doing, so it can show it while you are in another tab: working (with progress once the approved changes are known), waiting for approval (Apply web? 3 to create, 1 to update), done, or failed. A terminal that does not read these reports is sent none of them:

Sequence Sent to Shown as
OSC 7501, the Program Status Protocol Rex (REX_BLOCK set in its terminals) its tabs and session picker mark a program working, waiting for you, done or failed
OSC 9;4, ConEmu's progress Ghostty (TERM_PROGRAM=ghostty), Windows Terminal (WT_SESSION), ConEmu (ConEmuANSI=ON) a progress bar in the tab or taskbar, paused while waiting, removed when the run ends

OSC 9;4 goes to no other terminal: iTerm2 and others read OSC 9 as a notification. The reports carry what the run does, its scope and counts; nothing from configuration or state. nf tui tells the terminal the same about its runs.