Skip to content

Resource Lifecycle and Meta-Arguments Reference

Every Netherframe resource accepts provider arguments from its schema alongside a small, fixed set of framework meta-arguments. This page documents every meta-argument, every LifecycleRules option, write-only attributes, and exact hybrid vs. legacy synthesis behavior.


Construct meta-arguments

Argument Applies to Purpose
nf_scope All constructs Parent App, Stack, or Construct (optional inside with blocks or @autoscope).
nf_id All constructs Stable identifier within its scope (optional when injected by # coding: nf_autoid + Bind / BindContext).
nf_type Generic Resource, DataSource, EphemeralResource, Provider Terraform type string (for example, "aws_s3_bucket"). Set automatically by generated classes.
nf_provider Resource, DataSource, EphemeralResource Explicit provider instance to use instead of the active stack/context default.
depends_on Resource, DataSource, EphemeralResource Explicit sequence of prerequisite constructs when no direct attribute reference exists.
lifecycle Resource (LifecycleRules), DataSource (DataLifecycleRules) Lifecycle customization rules (see below).
runtime_checks Resource List of @runtime_check, @pre_apply_check, @post_apply_check, or @retained_check validators (hybrid only).
.import_from(id) Resource Method requesting plan-time adoption of an existing object by literal ID or runtime expression.

Rejected Terraform meta-arguments in hybrid execution

Hybrid execution intentionally fails closed on these Terraform-only meta-arguments:

Terraform feature Hybrid behavior Recommended Netherframe alternative
count / for_each Rejected at plan time Instantiate one construct per item in a normal Python for loop.
provisioner / connection Rejected at plan and apply time Use user data / cloud-init, baked images, or nf synth (legacy).
Move / Import constructs Rejected at plan time Use nf state mv and .import_from(...) / --adopt-from.

LifecycleRules reference

Import from nf.core:

from nf.core import LifecycleRules
Field Type Default Hybrid execution Legacy synthesis (nf synth)
prevent_destroy bool \| None None Blocks delete and replacement at plan time and refuses nf destroy before approval (also enforced from state for removed resources). Emits prevent_destroy = true in lifecycle.
ignore_changes list[str] \| Literal["all"] \| None None Copies prior-state values into planned config for listed paths ("tags", "tags[\"Name\"]", "rule[0].days", or "all"); ignored on fresh creates and replacements. Emits ignore_changes in lifecycle.
replace_triggered_by list[Any] \| None None Forces replacement whenever any referenced resource or attribute has a planned change; replacement is planned fresh with no prior state. Emits replace_triggered_by in lifecycle.
retain str \| Literal[False] \| None None Hybrid-only: retain="reason" keeps the live object and state entry across nf destroy (and removal plans), requires dependency closure to be retained unless dependents set retain=False, reads back from provider, and runs @retained_check. Omitted from synthesized lifecycle.
adopt bool \| Literal["required"] \| None None Hybrid-only: adopt=True adopts an existing object by provider resource identity (or creates if missing); adopt="required" errors if missing. Omitted from synthesized lifecycle.
create_before_destroy bool \| None None Rejected (fail closed) rather than silently approximating CBD. Emits create_before_destroy = true.
precondition / postcondition list[Condition] \| None None Rejected (fail closed) — use runtime_checks (@pre_apply_check, @post_apply_check) or app.check. Emits Terraform precondition / postcondition blocks.

Complete example

# coding: nf_autoid

from nf.core import App, Bind, BindContext, LifecycleRules, Stack
from nf.providers.hashicorp.aws import AwsProvider, S3Bucket, S3BucketVersioning

with App(nf_id="storage-demo") as app, Stack() as storage, BindContext:
    aws: Bind = AwsProvider(region="us-east-1")

    # Protect bucket against accidental deletion, ignore tags added by an external tagger,
    # and keep it managed in state during teardown
    audit_bucket: Bind = S3Bucket(
        nf_provider=aws,
        bucket="acme-audit-archive",
        lifecycle=LifecycleRules(
            prevent_destroy=True,
            ignore_changes=["tags"],
            retain="regulatory audit archive outlives environment teardown",
        ),
    )

    # Depends on audit_bucket; explicitly opts into being deleted on teardown if desired,
    # or inherits retention if not set to retain=False
    versioning: Bind = S3BucketVersioning(
        nf_provider=aws,
        bucket=audit_bucket.output.id,
        versioning_configuration=[{"status": "Enabled"}],
        depends_on=[audit_bucket],
        lifecycle=LifecycleRules(
            retain="versioning protects the retained audit bucket",
            replace_triggered_by=[audit_bucket],
        ),
    )

Write-only attributes (*_wo)

When a provider schema marks an argument as write_only (for example, aws_ssm_parameter.value_wo or GeneratedValue.write_only_params):

  • The value is sent to the provider only in the configuration payload during plan/apply.
  • Plans (including saved plans) and state store null for the attribute, and its value never triggers drift.
  • Increment the provider's companion version attribute (such as value_wo_version=2) to rotate the secret.

Replacement ordering

When a resource and one or more resources depending on it are replaced in the same run, hybrid execution destroys old objects in reverse dependency order and creates new objects in dependency order:

  1. Destroy dependent's old object (and delete any removed resources depending on the parent)
  2. Destroy parent's old object
  3. Create parent's new object
  4. Create dependent's new object

If destroying a dependent's old object fails, the parent's old object is left untouched.