Export Terraform configuration from a small app
Use legacy compatibility when an existing Terraform/OpenTofu workflow needs generated configuration. In this walkthrough you’ll define one AWS bucket and inspect the exported Terraform JSON. Synthesis runs locally without contacting AWS or creating a bucket. For a new project, start with your first hybrid app.
Before you start: Python 3.15+, a project with Netherframe installed,
and AWS Python bindings. If you do not have a published binding package, use
provider generation with hashicorp/aws.
No AWS credentials or Terraform executable are needed for these steps.
1. Add the provider package
From your uv project directory:
uv add netherframe.providers.hashicorp.aws
If you are using pip, install the same distribution with python -m pip install.
Keep the project's Python environment active for the nf commands below.
2. Register the app
Add this section to your existing pyproject.toml, keeping its [project] and dependency
settings. If [tool.nf] already exists, update that section instead of adding a second one.
[tool.nf]
legacy_apps = ["app:app"]
3. Create app.py
# coding: nf_autoid
from nf.core import App, Bind, BindContext, Output, Stack
from nf.providers.hashicorp.aws import AwsProvider, S3Bucket
with App(nf_id="hello-nf") as app, Stack() as storage, BindContext:
aws: Bind[AwsProvider] = AwsProvider(region="us-east-1")
assets: Bind[S3Bucket] = S3Bucket(
bucket="replace-with-a-globally-unique-name",
nf_provider=aws,
)
bucket_id: Bind = Output(value=assets.ref_id_)
The placeholder bucket name is sufficient for synthesis. Choose an unused, globally unique name and configure AWS credentials before you later plan or apply this AWS app.
4. Generate the configuration
nf synth
nf list stacks
The stack's configuration is written here:
.nf.out/
hello-nf/
storage/
nf.tf.json
Open nf.tf.json. Look for the AWS provider, aws_s3_bucket.assets and the bucket_id
output. The output is a reference such as ${aws_s3_bucket.assets.id}, because the bucket
ID will be known only after a provider creates or reads the object.
You have now completed the first authoring loop: Python code → synthesized configuration → inspection. You can change the bucket definition and synthesize again without making an infrastructure change.
Try the next step
- Hand the generated files to Terraform or OpenTofu. Compatibility workflow
- Try Netherframe-managed execution locally. First hybrid app
Understand the example
App discovery and object identity
app:app tells the CLI to import the Python module app and load its app object.
App(nf_id="hello-nf") gives that object the ID used in the output path.
The with statement enters the app first, so the stack belongs to the app. It then
enters the stack, so the provider, bucket and output belong to storage.
The first line enables the codec installed with Netherframe. BindContext takes
the stack ID from as storage, and Bind takes the provider, resource and output IDs
from their assignment names. Bind[S3Bucket] also gives editors the resource's type.
Keep IDs stable once objects are recorded in state. If you rename a Python binding,
you can pass the old ID explicitly as nf_id. See the codec guide.
Bindings and provider execution
AwsProvider and S3Bucket are generated Python classes. They build configuration during
synthesis; constructing them does not create cloud objects. The Terraform provider binary
is the component that later validates, reads and changes infrastructure.
The generated provider class records its provider source and version. The provider generation tutorial explains how that pin differs from a Python binding revision.
References and planning
assets.ref_id_ refers to the bucket's eventual ID; it is not an immediate AWS lookup.
References let nf carry dependencies through the app. Read
providers and runtime values before combining
resource outputs with other configuration.
Planning and applying are separate actions. This walkthrough deliberately ends before either. Choose your workflow explains how selectors choose direct execution or an external Terraform handoff.