Coming from CDK for Terraform (CDKTF)
If you are migrating off CDK for Terraform (CDKTF) in Python, Netherframe is the most direct, zero-compromise transition available:
- 100% native Python 3.15+ — no Node.js runtime, no JSII serialization overhead, no multi-gigabyte generated bindings.
- Same Terraform provider ecosystem — generate typed Python bindings for any provider
with
nf generate providers(with Ruff-formatted dataclasses and full IDE typing). - Direct gRPC execution by default — no shelling out to
terraformfor every plan and apply (while still supportingnf synthTerraform JSON export whenever an existing pipeline expects it). - Zero-recreate migration — adopt your existing CDKTF Terraform state directly into
Netherframe via
--adopt-fromand--terraform-state.
Side-by-side: CDKTF (Python) vs. Netherframe
from cdktf import App, TerraformOutput, TerraformStack
from cdktf_cdktf_provider_aws.provider import AwsProvider
from cdktf_cdktf_provider_aws.s3_bucket import S3Bucket
from constructs import Construct
class StorageStack(TerraformStack):
def __init__(self, scope: Construct, id: str) -> None:
super().__init__(scope, id)
AwsProvider(self, "aws", region="us-east-1")
bucket = S3Bucket(self, "assets", bucket="acme-cdktf-assets")
TerraformOutput(self, "bucket_id", value=bucket.id)
app = App()
StorageStack(app, "storage")
app.synth()
# coding: nf_autoid
from nf.core import App, Bind, BindContext, Output, Stack, autoscope
from nf.providers.hashicorp.aws import AwsProvider, S3Bucket
@autoscope
class StorageStack(Stack):
def __init__(self, *, nf_scope: App | None = None, nf_id: str | None = None) -> None:
super().__init__(nf_scope=nf_scope, nf_id=nf_id)
aws: Bind = AwsProvider(region="us-east-1")
self.assets: Bind[S3Bucket] = S3Bucket(bucket="acme-cdktf-assets")
bucket_id: Bind = Output(value=self.assets.output.id)
def app() -> App:
with App(nf_id="platform") as app, BindContext:
storage: Bind = StorageStack()
return app
Command and concept rosetta stone
| CDKTF | Netherframe equivalent | Notes |
|---|---|---|
cdktf.json |
pyproject.toml ([tool.nf] + [tool.nf.config]) |
Standard Python project metadata; no separate JSON config file. |
cdktf get |
nf generate providers hashicorp/aws --version ... |
Generates a native Python package (netherframe.providers.hashicorp.aws) with keyword-only nested block dataclasses. |
cdktf diff |
nf plan --app <app> --diff --out plan.json |
Direct gRPC provider refresh and diff—no Terraform subprocess required. |
cdktf deploy |
nf apply --app <app> --plan-file plan.json (or nf deploy) |
Supports automatic ROLLBACK, @app.check gates, finalizers, and deferred provider rounds. |
cdktf destroy |
nf destroy --app <app> |
Reuses applied deployment inputs; supports managed LifecycleRules(retain=...). |
cdktf synth |
nf synth (for [tool.nf].terraform_apps) |
Optional legacy compatibility path that exports .nf.out/<app>/<stack>/nf.tf.json. |
TerraformStack / TerraformOutput |
Stack / Output |
Stacks in one App share one whole-app dependency graph. |
TerraformVariable / TerraformLocal |
App factory parameters (++name=value) / plain Python variables |
Type-checked inputs without Terraform variable plumbing. |
DataTerraformRemoteState |
Direct Python attribute reference (network.vpc.output.id) |
Cross-stack references work directly across stacks in the same App. |
Token.as_string(...) / Fn.* |
RuntimeValue expressions, f-strings, and @hybrid_runtime |
Hybrid mode evaluates Python directly instead of serializing HCL Fn.* strings. |
cdktf.Testing.synth(...) |
app.synth(outdir=tmp_path) + pytest |
Pure Python tests with millisecond startup. |
Migrating an existing CDKTF project without recreating resources
Because CDKTF stores standard Terraform state (terraform.tfstate locally or in S3/GCS),
you can transition to Netherframe in two clean ways:
Option A: Adopt existing CDKTF state directly into hybrid execution (recommended)
- Generate bindings for the provider versions your CDKTF stacks use (
nf generate providers ...). - Translate your
TerraformStackclasses into NetherframeStackclasses (keeping clean, readablenf_idvalues instead of CDKTF's hashed IDs). - Pull your existing state (
terraform state pull > cdktf.tfstate) and map each old CDKTF Terraform address to its new Netherframe address in an adoption manifest:
{
"format_version": 1,
"terraform_state": "cdktf.tfstate",
"adopt": {
"storage.aws_s3_bucket.assets": {"terraform_address": "aws_s3_bucket.assets_A1B2C3D4"}
}
}
- Plan and verify every resource imports cleanly with zero replacements:
nf plan --app app --adopt-from storage.adopt.json --diff --adopt-missing error --out migrate.plan.json nf apply --app app --plan-file migrate.plan.json
(Alternatively, run nf convert directly on CDKTF's synthesized cdktf.out/stacks/<stack>/
JSON if you want Netherframe to scaffold the Python and adoption manifest automatically.)
Option B: Keep your existing Terraform runner first (nf synth)
Register the ported app under [tool.nf].terraform_apps, run nf synth, and point your
existing Terraform/OpenTofu pipeline at .nf.out/ while validating parity, then switch to
hybrid execution when ready.
Next steps
- CDK/CDKTF AWS walkthrough: Quickstart for CDK and CDKTF users
- Importing from Terraform state: How to Import (Adopt) Existing Resources
- Migration tutorial: Convert a Terraform project