Skip to content

Coming from AWS CDK

If you use AWS CDK in Python, Netherframe's construct tree (App, Stack, Construct, Output) will feel immediately familiar. The biggest differences are under the hood: Netherframe is 100% native Python 3.15+ (no Node.js, no JSII runtime bridge), talks directly to Terraform providers over gRPC instead of synthesizing CloudFormation templates, and manages any cloud or SaaS provider in one unified graph.


Side-by-side: AWS CDK (Python) vs. Netherframe

import aws_cdk as cdk
from aws_cdk import aws_ec2 as ec2, aws_s3 as s3
from constructs import Construct


class PlatformStack(cdk.Stack):
    def __init__(self, scope: Construct, construct_id: str, **kwargs) -> None:
        super().__init__(scope, construct_id, **kwargs)

        vpc = ec2.CfnVPC(self, "MainVpc", cidr_block="10.55.0.0/16")
        bucket = s3.Bucket(
            self,
            "Assets",
            bucket_name="acme-platform-assets",
            removal_policy=cdk.RemovalPolicy.RETAIN,
        )
        cdk.CfnOutput(self, "VpcId", value=vpc.ref)
        cdk.CfnOutput(self, "BucketName", value=bucket.bucket_name)


app = cdk.App()
PlatformStack(app, "platform")
app.synth()
# coding: nf_autoid

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


@autoscope
class PlatformStack(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.vpc: Bind[Vpc] = Vpc(cidr_block="10.55.0.0/16")
        self.assets: Bind[S3Bucket] = S3Bucket(
            bucket="acme-platform-assets",
            lifecycle=LifecycleRules(retain="platform assets outlive teardown"),
        )
        vpc_id: Bind = Output(value=self.vpc.output.id)
        bucket_name: Bind = Output(value=self.assets.output.bucket)


def app() -> App:
    with App(nf_id="platform") as app, BindContext:
        platform: Bind = PlatformStack()
    return app

Command and concept rosetta stone

AWS CDK Netherframe equivalent Notes
cdk diff nf plan --app <app> --diff Refreshes live provider state and shows a tree diff with attribute changes; save with --out.
cdk deploy nf apply --app <app> or nf deploy --app <app> Calls providers directly over gRPC—no CloudFormation deployment wait or 500-resource stack limit.
cdk destroy nf destroy --app <app> Reuses applied deployment inputs; honors LifecycleRules(retain=...) while keeping retained objects managed and verified.
cdk bootstrap nf backend bootstrap or bootstrap_backend = true Bootstraps S3 state storage & locking (or use local/PostgreSQL state with zero bootstrap).
cdk.Token / Fn.sub RuntimeValue + Python f-strings (f"arn:...:{vpc.output.id}") Standard Python operators and f-strings carry dependency edges directly.
scope, id on every constructor with Stack(): + @autoscope + # coding: nf_autoid (Bind) Explicit Bind annotations inject deterministic nf_id values from variable names—or pass nf_scope=/nf_id= explicitly.
RemovalPolicy.RETAIN LifecycleRules(retain="why") + @retained_check Kept resources remain tracked in state and verified after teardown instead of becoming orphaned.
cdk.json context (-c env=prod) App factory parameters (++env=prod, ++@prod.toml) Type-checked against Python annotations before any provider runs; Secret[T] blocked from CLI argv.
CDK Aspects / cdk-nag nf lint (netherframe.lint.hashicorp.aws) + app.check(...) Offline AWS policy pack plus run-time prerequisites / plan / apply / finalize checks.
assertions.Template.from_stack(...) app.synth(outdir=tmp_path) + pytest Pure Python unit tests run in milliseconds without Node/JSII startup overhead.

Key mental shifts from AWS CDK

  1. Direct Terraform providers (L1 schema fidelity), your own L2s: Generated provider packages (nf.providers.hashicorp.aws) map 1:1 to Terraform's provider schemas—like strongly-typed L1 constructs. Build your own clean Stack or Construct classes for team-level L2 patterns without fighting opaque generated CloudFormation logical IDs.
  2. Addresses stay readable and explicit: Instead of hashed CloudFormation logical IDs (MainVpc3F8A21C9), every resource has a transparent address <stack>.<type>.<nf_id> (for example, platform.aws_vpc.vpc). Keep nf_id stable across refactors, or rename state cleanly with nf state mv.
  3. Whole-app plans: nf plan --app app plans every stack in the app as one dependency graph. Use separate Apps when you want separate state files and independent approvals.
  4. No JSII or Node.js dependency: Everything—from construct construction to gRPC provider orchestration and pytest—runs natively in Python 3.15+.

Next steps