Skip to content

Using Generated Provider Bindings

Netherframe generates standard Python packages directly from any Terraform provider's schema (nf generate providers). Because every resource still mirrors the upstream Terraform provider schema, you can read the official Terraform Registry documentation for any provider and translate it straight into typed Netherframe Python using the rules on this page.

For the hands-on generation workflow, see Generate and use a provider package.


1. Distribution name vs. Python import path

Artifact Example (hashicorp/aws) Notes
Package / distribution name netherframe.providers.hashicorp.aws Used in uv add, pip install, and pyproject.toml.
Short Python import from nf.providers.hashicorp.aws import ... Permanent alias returning the exact same module objects as netherframe.*.
Canonical Python import from netherframe.providers.hashicorp.aws import ... Equivalent at runtime and in static type checkers (ty, mypy, pyright).

2. How Terraform names map to Python classes

Generated classes strip the provider prefix from Terraform type names and convert to PascalCase:

Terraform schema construct Example Terraform name Generated Python class
Provider provider "aws" AwsProvider
Managed resource aws_s3_bucket, random_pet S3Bucket, Pet
Data source data "aws_ami" AmiDataSource
Ephemeral resource ephemeral "aws_secretsmanager_random_password" SecretsmanagerRandomPasswordEphemeralResource
List resource list "aws_instance" InstanceListResource
Action provider action restart_instance RestartInstanceAction
State store provider state store *StateStore

3. Reserved Python keyword escaping

Terraform schema arguments that collide with Python keywords or core builtins receive a trailing underscore _:

Terraform attribute name Python parameter name
type type_ (for example, SsmParameter(type_="String", ...))
id id_
from from_
import import_
class class_
pass pass_
global global_
async / await async_ / await_

Always trust your editor's autocomplete or nf providers describe rather than guessing spelling from HCL.


4. Nested blocks: Typed dataclasses vs. dicts

Generated nested block classes are kw_only=True dataclasses (and Plugin Framework nested_type attributes also generate typed dataclasses). You can pass either the typed dataclass or a plain dictionary matching the schema:

# coding: nf_autoid

from nf.core import App, Bind, BindContext, Stack
from nf.providers.hashicorp.aws import AwsProvider, DynamodbTable

with App(nf_id="blocks-demo") as app, Stack() as data, BindContext:
    aws: Bind = AwsProvider(region="us-east-1")
    orders: Bind = DynamodbTable(
        nf_provider=aws,
        name="orders",
        billing_mode="PAY_PER_REQUEST",
        hash_key="order_id",
        attribute=[{"name": "order_id", "type": "S"}],
        point_in_time_recovery=[{"enabled": True}],
    )

5. Referencing computed attributes (.output.<attr> vs. .ref_<attr>_)

Generated resources support both styles for referencing computed attributes—both return a typed RuntimeValue:

Style Example When to prefer
.output.<attr> bucket.output.id, vpc.output.arn Consistent across both generated classes and generic Resource(nf_type=...); recommended default in docs and examples.
.ref_<attr>_ bucket.ref_id_, vpc.ref_arn_ Explicit schema-generated properties with full static IDE autocomplete for every computed attribute on that resource type.

6. Binding a resource to a provider

When a stack has multiple providers (for example, multi-region or multi-account), bind resources using whichever style reads clearest:

# coding: nf_autoid

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

with App(nf_id="binding-styles") as app, Stack() as multi, BindContext:
    east: Bind = AwsProvider(region="us-east-1")
    west: Bind = AwsProvider(region="us-west-2")

    # 1. Explicit nf_provider= argument
    primary: Bind = S3Bucket(nf_provider=east, bucket="acme-primary-east")

    # 2. Provider context block
    with west:
        replica: Bind = S3Bucket(bucket="acme-replica-west")

    # 3. Provider-bound factory method
    archive: Bind = east.S3Bucket(bucket="acme-archive-east")

7. Inspecting provider packages from the CLI

Use the nf providers commands to explore installed or available bindings without leaving your terminal:

# List installed provider packages and curated provider sets
nf providers list
nf providers list --sets-only

# Search for providers matching a term
nf providers search kubernetes

# Describe a provider package's version pin, resources, and metadata
nf providers describe hashicorp/aws

8. Versions, binary pins, and binding revisions

Python binding wheels and Terraform provider executables are separate artifacts:

  • Provider 6.73.0 initially generates Python distribution version 6.73.0 (pinned to binary 6.73.0).
  • A binding-only fix uses --binding-revision 1 to publish 6.73.0.1 while keeping the provider binary pin at 6.73.0.
  • Each generated package ships _generation.json recording the provider pin, generator version, core floor, and schema fingerprint.
  • Generated hashicorp/aws bindings automatically declare netherframe.ext.aws (state normalization and graph contracts) as a dependency; they do not pull in the optional netherframe.lint.hashicorp.aws lint pack.