Skip to content

Settings

Every setting Netherframe takes has a key, such as max_concurrent_resources. A setting's value is the first of:

  1. its flag on the command line (nf --max-concurrent-resources 20 apply)
  2. its key in [tool.nf.config] in pyproject.toml
  3. the App's argument (or the state backend's, for graph state and PostgreSQL settings)
  4. your own default, in your config file (~/.config/nf/config.toml)
  5. its default

[tool.nf.config] outranks the App's arguments: an argument is the app's own default, and the project's configuration overrides it for every app. Your config file comes after both: it holds your defaults for every project, and a project's configuration or its code says otherwise for that project.

Nothing is read from the environment. Netherframe reads no NF_* variables, so a variable exported earlier in a shell cannot change a run: every value that shapes it is on its command line, in pyproject.toml or in the app's code. App inputs follow the same rule (nf vars). The few variables Netherframe still honors are listed at the end.

A relative path in a setting that names a file or directory (provider_cache_dir, a provider_mirrors directory, backend_local_path, adopt_from...) is in the project's root, whichever of the places above gives it: the working directory for nf, the Project's root through the Python API.

Giving Settings

Flags

Global settings are options of nf itself, shown in groups by nf --help. They may be written before or after the command:

nf --graph-lease-ttl 300 apply --app web
nf apply --app web --graph-lease-ttl 300

A setting that is on or off has both forms: --drift-correction and --no-drift-correction. Command settings are options of their commands only (nf apply --recovery-strategy rollback). A process nf starts to build an app (legacy synthesis) gets the flags nf was given.

[tool.nf.config]

Settings a project always uses go in the [tool.nf.config] table of the pyproject.toml found from the working directory upwards. Keys are the setting keys below, values TOML values:

[tool.nf.config]
max_concurrent_resources = 20
recovery_strategy = "rollback"
provider_apply_timeout = 3600
graph_lease_ttl = 300
backend_type = "s3"
backend_s3_bucket = "acme-state"
postgresql_password_file = "/run/secrets/postgresql-password"

[tool.nf.config] is not [tool.nf]: [tool.nf] lists the project's apps (apps / hybrid_apps, terraform_apps / legacy_apps) and how the CLI runs them, and [tool.nf.tui] holds the TUI's own options. See Configuration and Precedence Model.

Your config file

Your config file holds your defaults for the flags that belong to your machine rather than to a project, in every project, each written as on the command line without its dashes. nf reads $XDG_CONFIG_HOME/nf/config.toml when XDG_CONFIG_HOME is set (to an absolute path, as the XDG specification requires) and the file is there, else ~/.config/nf/config.toml (on Windows, %APPDATA%\nf\config.toml), or the file nf --user-config FILE names:

# ~/.config/nf/config.toml
log-level = "INFO"
provider-mirror = ["https://artifactory.example.com/artifactory/api/terraform/tf/providers/"]
provider-credentials-file = "~/.terraform.d/credentials.tfrc.json"

[tui]
keymap = "emacs"
skin = "light"

At the top: where providers are installed from and kept (Installing Providers: provider-mirror, provider-mirror-include, provider-direct, provider-credentials-file, provider-ca-bundle, provider-cache-dir, schema-cache-dir, provider-version-cache-dir), non-interactive, and log-level, log-format and trace. Under [tui], nf tui's skin, keymap, graph-lines, refresh and readonly. Nothing else: a setting that shapes what a run does (recovery-strategy, max-concurrent-resources, a state backend) belongs to the project ([tool.nf.config], the App) or to the command line, so that a run does not depend on who runs it; and a flag of one command line (--app, --auto-approve) is not a default. Values are checked as flags are; a name nf does not know, a setting the file may not hold, or a value a flag would not take stops nf saying which and where. nf --help, nf COMMAND --help and nf --version still answer, with the problem on standard error.

A flag on the command line wins over the file, and so do the project's configuration ([tool.nf.config], and [tool.nf.tui] for nf tui) and the app's arguments. nf --no-user-config leaves the file out, for a command that must not depend on who runs it (a CI job, a bug report). A process nf starts to build an app (legacy synthesis) gets your defaults with its flags.

The file is read by the nf command; code that embeds Netherframe or calls nf.sdk does not read it.

Code that embeds Netherframe

Code that builds apps without the CLI (a script, a test, another tool) gives flags with nf.core.config.flags, or calls the commands through nf.sdk with Project(settings=...). Flags rank above [tool.nf.config] and App arguments. They belong to the current context, never to the process: set_flags gives them for the rest of it, flags for a while. They follow a run into the threads and tasks Netherframe starts; a thread of your own sees them only if it runs in a copy of the context (contextvars.copy_context().run).

from nf.core import App
from nf.core.config.flags import flags, set_flags


def build_app() -> App:
    return App(nf_id="web")


set_flags({"max_concurrent_resources": 20, "provider_apply_timeout": 3600})

# For a while, then as they were (tests)
with flags(drift_correction=False, recovery_strategy="rollback"):
    app = build_app()

Give them before building the app: App(...) reads its settings when it is constructed.

Settings of nf

These are options of nf itself, for every command that builds an app. The "Argument" column names the argument that sets the same thing in code, where there is one.

Building apps

Key Flag Argument Default Meaning
disable_validation --disable-validation App(disable_validation=) off Skip validating constructs
deferred_validation --deferred-validation App(deferred_validation=) off Validate all constructs at synthesis, reporting every error at once
validation_report_file --validation-report-file FILE none Write deferred validation errors to this file
enable_circular_dep_resolution --circular-dep-resolution App(enable_circular_dep_resolution=) off Resolve circular dependencies in phases
legacy_binary --legacy-binary PATH terraform Terraform or OpenTofu binary for legacy apps; a command's own --legacy-bin wins

Running

Key Flag Argument Default Meaning
max_concurrent_resources --max-concurrent-resources N App(max_concurrent_resources=) 10 Resources changed at once; nf plan, nf apply and nf deploy also take --parallelism N
max_concurrent_reads --max-concurrent-reads N App(max_concurrent_reads=) 40 Refresh and plan calls at once; also --read-parallelism N
drift_correction --drift-correction App(drift_correction=) on Graph plans correct drift
state_persist_interval --state-persist-interval SECONDS 20 Seconds between state writes during an apply; 0 writes each change at once
enable_progress_reporting --progress-reporting App(enable_progress_reporting=) on Report each resource's progress
non_interactive --non-interactive off No live display, one line per event as on CI; the display is live only on a terminal and outside CI
anyio_backend --anyio-backend asyncio\|trio asyncio Event loop

Providers

Key Flag Default Meaning
provider_apply_timeout --provider-apply-timeout SECONDS none Stop waiting for a provider to apply a change after this long; 0 is none, as in Terraform
provider_handshake_timeout --provider-handshake-timeout SECONDS 10 Wait this long for a provider to start
provider_schema_timeout --provider-schema-timeout SECONDS 120 Wait this long for a provider's schema
provider_cache_dir --provider-cache-dir DIR ~/.nf/providers Provider binaries
schema_cache_dir --schema-cache-dir DIR ~/.nf/schema_cache Provider schemas
provider_version_cache_dir --provider-version-cache-dir DIR ~/.cache/nf/provider-versions Provider versions nf generate providers looked up (kept 24 hours)
provider_mirrors --provider-mirror URL\|DIR (repeated) none Mirrors, asked in order: an https URL is a provider network mirror (Artifactory, Nexus...), anything else a directory laid out as terraform providers mirror writes it; in [tool.nf.config], a list of those or of tables ({ url = "...", include = [...], exclude = [...] }, { path = "..." })
provider_mirror_include --provider-mirror-include PATTERNS all The providers served by mirrors that name none of their own (hashicorp/*, example.com/*/*; comma-separated, or a list in [tool.nf.config]); the rest come from their registries
provider_direct --provider-direct on, unless a mirror serves every provider Also fetch providers from their own registries
provider_credentials_file --provider-credentials-file FILE none Tokens for registries and mirrors, in the shape of Terraform's credentials.tfrc.json
provider_ca_bundle --provider-ca-bundle FILE the system's Also trust these PEM certificates when fetching providers

provider_apply_timeout has no default on purpose: creates such as RDS, EKS or CloudFront can take far longer than any fixed limit, and a client that stops waiting leaves the provider working with nothing recorded in state.

Graph state

Settings of the graph state backend. The argument is PostgreSQLGraphBackend's.

Key Flag Argument Default Meaning
graph_lease_ttl --graph-lease-ttl SECONDS lease_ttl 120 How long a run's leases last after each renewal
graph_lease_renew_interval --graph-lease-renew-interval SECONDS lease_renew_interval a quarter of the TTL How often leases renew; must be under the TTL
graph_lease_timeout --graph-lease-timeout SECONDS lease_timeout 0 Wait this long for the app's grant after planning, per attempt; 0 tries once
graph_approval_timeout --graph-approval-timeout SECONDS approval_timeout 300 Wait this long for each approval, deferred rounds included
operation_quiescence --operation-quiescence SECONDS operation_quiescence provider_apply_timeout when set, else none When a dispatched call can no longer take effect; without one, recovering a dispatched operation needs --confirm-terminated
kill_providers_on_lease_loss --kill-providers-on-lease-loss kill_providers_on_lease_loss on Kill the run's providers when it loses its lease, and record it for recovery
graph_history_retention_days --graph-history-retention-days DAYS history_retention_days 90 Keep committed versions this long

State backends

The backend_* settings choose the state backend of everything whose code names none: a hybrid app's state, a legacy stack's Terraform backend block, and the state nf drift reads. Without them it is local; nothing is saved. nf backend show shows the backend and where each value came from (see nf backend). The postgresql_* settings connect both PostgreSQL backends; their argument is the backend's host, port, database, username, ssl_mode or (graph state) password_file.

Key Flag Default Meaning
backend_type --backend-type TYPE local The state backend where the code names none: local, s3; another type gets a legacy backend block without options
backend_s3_bucket --backend-s3-bucket NAME none Its S3 bucket
backend_s3_key_prefix --backend-s3-key-prefix PREFIX none What its keys start with: a hybrid app's state is PREFIX/nf.tfstate, a legacy stack's PREFIX/STACK/terraform.tfstate
backend_s3_region --backend-s3-region REGION AWS_DEFAULT_REGION Its S3 region
backend_s3_profile --backend-s3-profile PROFILE the AWS SDK's credential chain The AWS profile it reads and writes state with (and a legacy stack's backend block names)
backend_local_path --backend-local-path FILE .nf.out/nf.tfstate (hybrid) Its local state file
bootstrap_backend --bootstrap-backend off Create the state backend's storage (an S3 bucket and lock table) on the first apply that needs it, with the app's own provider; a plan before then plans against empty state
bootstrap_backend_provider --bootstrap-backend-provider [STACK.]aws[.ALIAS] the app's own The app's provider configuration to create it with
postgresql_host --postgresql-host HOST localhost PostgreSQL state host
postgresql_port --postgresql-port PORT 5432 PostgreSQL state port
postgresql_database --postgresql-database NAME none PostgreSQL state database
postgresql_username --postgresql-username NAME none PostgreSQL state user
postgresql_ssl_mode --postgresql-ssl-mode MODE prefer PostgreSQL SSL mode
postgresql_password_file --postgresql-password-file FILE none File holding the PostgreSQL password

The password itself is never a flag or a setting. It comes from a file: a mounted secret, or process substitution (--postgresql-password-file <(vault kv get -field=password secret/nf)). In code, the graph backend also takes password_source, a callable that returns it (a secrets manager client), and the document PostgreSQLBackend takes password=.

Command Settings

These are options of the commands named, and keys of [tool.nf.config] like any other.

nf apply, nf destroy and nf deploy

Key Flag Argument Default Meaning
recovery_strategy --recovery-strategy checkpoint\|rollback\|none App(recovery_strategy=) checkpoint What a failed run does (see Rollback and Recovery)
run_status --run-status App(run_status=) on Keep the run's live status beside its state for nf follow and nf tui

nf plan, nf apply and nf deploy

nf plan takes --provenance-report and --graph-plan-scope only; the others are flags of nf apply and nf deploy. See Deferred Provider Configuration.

Key Flag Argument Default Meaning
apply_deferred --apply-deferred App(apply_deferred=) off Let a saved plan or an auto-approved apply plan and apply its deferred changes in the same run
deferred_approval --deferred-approval MODE App(deferred_approval=) each_round How deferred rounds are approved: each_round, once, auto (needs apply_deferred) or always
incomplete_exit_code --incomplete-exit-code N App(incomplete_exit_code=) 4 Exit code of a successful apply that left deferred changes; 0 treats it as converged
allow_legacy_plan_drift App(allow_legacy_plan_drift=) off Downgrade known-value final-plan drift on legacy Plugin SDK providers from an error to a warning
provider_data_sources --provider-data-sources read\|state App(provider_data_sources=) read Read the data sources a provider's settings refer to before configuring it, or take them from state (not recommended)
deleted_objects --deleted-objects review\|recreate\|error App(deleted_objects=) review An object deleted outside Netherframe: re-create it after review (refused under --auto-approve), re-create it unattended, or fail the plan
provenance_report --provenance-report App(provenance_report=) off Report what the plan or apply reads of state (Provenance Report)
concurrent_applies --concurrent-applies App(concurrent_applies=) off Use graph resource grants instead of app-wide exclusion
graph_plan_scope --graph-plan-scope full\|affected App(graph_plan_scope=) full Plan the whole app, or the dependency closure of what changed (graph state with a retained baseline)

Adopting existing objects (nf plan and nf apply)

See Adopting Existing Infrastructure.

Key Flag Argument Default Meaning
approve_imports nf apply --approve-imports App(approve_imports=) off Let --auto-approve approve imports
adopt_missing --adopt-missing create\|error App(adopt_missing=) create What a plan does when an object to adopt is not found
allow_duplicate_adoption --allow-duplicate-adoption App(allow_duplicate_adoption=) off Adopt an object state holds under another address
adopt_from --adopt-from FILE App(adopt_from=) none The adoption manifest
adopt_terraform_state --terraform-state FILE App(adopt_terraform_state=) none The Terraform state of the manifest's terraform_address entries

Other commands

Key Flag Default Meaning
outdir nf synth --outdir DIR .nf.out Where synthesis writes; app.synth(outdir=) in code
bootstrap_aws_provider_version nf backend bootstrap --aws-provider-version VERSION the newest cached, else the latest hashicorp/aws version that creates the S3 backend's resources
generation_schema_loading nf generate providers --schema-loading disk\|memory disk How provider generation loads schemas
generation_max_workers nf generate providers --max-workers N up to 4 Threads generating each provider

[tool.nf] outdir is separate: it tells the CLI's inventory commands where to look for synthesized output.

Logging

Logging options are options of nf itself, written before or after the command like global settings. They are not keys of [tool.nf.config].

Option Meaning
--log-level TRACE\|DEBUG\|INFO\|WARNING\|ERROR Log at this level
--log-format text\|json\|pretty Log in this format
--trace Log at TRACE

Without them, nf logs nothing. At DEBUG and TRACE it also logs each resource as apps are built.

Code that embeds Netherframe is silent by default (NullHandler only on the "netherframe" stdlib logger) so logs flow into the host application's own stdlib logging or structlog handlers, or configures logging explicitly with nf.core.logging.configure_logging(level=..., log_format=...) and turns it off with disable_logging(). At DEBUG and below, resources also log as they are built, and a process nf starts logs as nf does. See Logging, Debugging and Performance.

Environment Variables

Netherframe reads no NF_* variable. It still honors a few others, none its own:

Variable Effect
CI Set, nf draws no live display, as --non-interactive
AWS_DEFAULT_REGION The AWS SDK's own: the detected S3 backend's region when backend_s3_region is not set
GRPC_ENABLE_FORK_SUPPORT gRPC's own. The nf command sets it to 0 unless it is set, avoiding fork diagnostics as it starts providers; set 1 before starting nf to opt out. See gRPC fork diagnostics
TF_WORKSPACE Terraform's own: with a prefix, the workspace of the remote (HCP Terraform) backend, as Terraform selects it
VISUAL, EDITOR The editor nf tui opens a resource's declaration in
NO_COLOR nf tui draws in monochrome

Providers read their own variables (AWS credentials and the like), as they do under Terraform.

Test and development knobs are pytest options, not variables: pytest --nf-use-fakecloud, --nf-use-containers, --nf-update-golden and the like. See Testing.