Skip to content

nf state

Manage a configured hybrid app's state or pass state operations through to a synthesized legacy stack.

Synopsis

nf state [OPTIONS] [TERRAFORM_ARGS]...

Main Use

This command is a thin pass-through to legacy CLI state operations in the selected synthesized stack directory.

Examples:

nf state --stack network list
nf state --stack network show aws_vpc.vpc

Hybrid Apps

These subcommands act on a hybrid app's own state, in any state backend (choose the app with --app when the project has several); with --stack they run Terraform's command in the stack instead:

  • nf state force-unlock LOCK_ID: release the state lock of a run that crashed
  • nf state taint ADDRESS: mark an object tainted, so the next plan replaces it
  • nf state untaint ADDRESS: clear an object's tainted mark, so the next plan keeps it (state migrated from Terraform keeps the objects Terraform tainted)
  • nf state mv SOURCE TARGET [--auto-approve]: move an object's state entry to another address after renaming its nf_id (direct execution does not plan Move blocks), so the next plan keeps the object instead of deleting and recreating it. The entries that depend on it are rewritten to its new address in the same write. A move to another resource type asks the target's provider to convert the stored state. Infrastructure is unchanged
  • nf state rm ADDRESS...: remove resources and outputs (<stack>.output.<name>) from state, in one write, so the app no longer manages them; infrastructure is unchanged. An entry that depends on a removed one must be named too, or no longer depend on it (apply a configuration without the dependency first): rm refuses to leave it dangling, and removes nothing then. While the app still declares a removed resource, the next plan creates it again; remove it from the code too, or adopt the object back (import_from, nf plan --adopt-from)
nf state taint web.aws_instance.server
nf state untaint web.aws_instance.server --app app
nf state mv web.aws_instance.server web.aws_instance.frontend --app app
nf state rm web.aws_instance.server web.aws_eip.server_ip --app app

Run records

nf state --app demo runs            # runs whose finalizers did not finish
nf state --app demo runs --all
nf state --app demo verify          # finalize the newest unresolved run
nf state --app demo verify 20261120T120000.000000000Z-1a2b3c4d
nf state --app demo abandon 20261120T120000.000000000Z-1a2b3c4d

A run of an app with finalizers keeps a run record beside its state (local and S3 state). verify takes the state lock and runs the finalizers again for a run stopped hard (or whose finalizers failed), refusing when another run wrote state since; abandon gives up on one. Unresolved records are never pruned.

Graph onboarding and recovery

nf state --app demo onboard --local
nf state --app demo onboard --graph graph.json
nf state --app demo onboard  # resume the recorded handoff
nf state --app demo operations
nf state --app demo recover
nf state --app demo baseline pin

onboard migrates the app's configured document state, including S3, reviews reconciliation of identity and intent, and writes nf.baseline. --local uses durable PostgreSQL in Docker; --graph FILE selects a PostgreSQL backend described by JSON. Keep the routing receipt and local credentials under .nf.out; later CLI invocations use the recorded graph destination. --auto-approve approves reconciliation and --baseline-file FILE selects the baseline path. An interrupted run can resume using the same destination.

See Graph state for the configuration format, recovery, history, query and low-level migration commands.

Options

  • --stack, -s TEXT: stack selector
  • --app TEXT: hybrid app selector
  • --legacy-bin TEXT: path to the legacy CLI binary
  • --outdir PATH: synthesized output directory override

Safety Guidance

State operations are powerful and can be disruptive. Use them when you know exactly what you are changing and prefer normal plan/apply flows when possible.