Skip to content

Coming from AWS CloudFormation

If you come from AWS CloudFormation (or AWS SAM / Troposphere), you already value automatic rollback on failure, change sets before execution, and DeletionPolicy: Retain. Netherframe brings those same operational guarantees to typed Python and the full multi-cloud Terraform provider ecosystem—without CloudFormation's 500-resource stack ceiling, YAML intrinsic-function gymnastics, or AWS-only lock-in.


Side-by-side: CloudFormation YAML vs. Netherframe Python

AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  Env:
    Type: String
    Default: dev
    AllowedValues: [dev, prod]
Resources:
  OrdersTable:
    Type: AWS::DynamoDB::Table
    DeletionPolicy: Retain
    Properties:
      TableName: !Sub "orders-${Env}"
      BillingMode: PAY_PER_REQUEST
      AttributeDefinitions:
        - AttributeName: order_id
          AttributeType: S
      KeySchema:
        - AttributeName: order_id
          KeyType: HASH
  EventsQueue:
    Type: AWS::SQS::Queue
    Properties:
      QueueName: !Sub "orders-${Env}-events"
Outputs:
  TableName:
    Value: !Ref OrdersTable
# coding: nf_autoid

from typing import Literal

from nf.core import App, Bind, BindContext, LifecycleRules, Output, Stack, Teardown
from nf.providers.hashicorp.aws import AwsProvider, DynamodbTable, SqsQueue


def orders(
    env: Literal["dev", "prod"] = "dev",
    region: str = "us-east-1",
    keep_orders: Teardown[bool] = True,
) -> App:
    with App(nf_id="orders", recovery_strategy="ROLLBACK") as app, Stack(nf_id=f"orders-{env}"), BindContext:
        aws: Bind = AwsProvider(region=region)
        table: Bind = DynamodbTable(
            nf_provider=aws,
            name=f"orders-{env}",
            billing_mode="PAY_PER_REQUEST",
            hash_key="order_id",
            attribute=[{"name": "order_id", "type": "S"}],
            lifecycle=LifecycleRules(retain="order history outlives teardown") if keep_orders else None,
        )
        events: Bind = SqsQueue(nf_provider=aws, name=f"orders-{env}-events")
        table_name: Bind = Output(value=table.output.name)
    return app

Concept rosetta stone

CloudFormation Netherframe equivalent Notes
Template (YAML/JSON) Python App factory + Stacks Full Python types, loops, modules, and offline pytest unit testing.
Parameters Typed app factory parameters (++env=prod) Validated against Python annotations (Literal, int, dataclass); deployment inputs are recorded in state for nf destroy.
!Ref, !GetAtt, !Sub resource.output.<attr> and f-strings (f"arn:...:{bucket.output.id}") Preserves dependency edges automatically; Expression.__bool__ fails fast on invalid Python branching.
Change Set (create-change-set / execute-change-set) nf plan --out plan.json → nf apply --plan-file plan.json Immutable, SHA-256 digest-verified whole-app plan artifact.
Automatic stack rollback App(recovery_strategy="ROLLBACK") Deletes resources created by a failing apply across any provider (AWS, GCP, Kubernetes, Datadog, etc.).
DeletionPolicy: Retain LifecycleRules(retain="why") + @retained_check Unlike CloudFormation (which orphans retained resources after stack deletion), Netherframe keeps them managed in state, protects their dependencies, and verifies them after nf destroy.
StackSets (multi-region / multi-account) for region in regions: AwsProvider(region=region) Fan out across regions and accounts in one dependency graph (see examples/aws_multi_region).
Custom Resources (Lambda-backed) @hybrid_runtime functions or DataSource Run ordinary Python during apply without deploying and maintaining wrapper Lambdas.
cfn-lint / cfn-guard nf lint (netherframe.lint.hashicorp.aws) + app.check(...) 1,899+ native Python AWS policy checks offline plus run-time prerequisites / plan / apply / finalize guards.
Drift detection (detect-stack-drift) nf plan --expect-no-changes and nf drift detect\|check\|fix Live refresh against providers; exits 3 on drift for CI.
Nested stacks / Export + Fn::ImportValue Multiple Stacks in one App with direct Python references No rigid export locks blocking updates in upstream stacks.

Key mental shifts from CloudFormation

  1. You choose where state lives. CloudFormation stores state inside the AWS service itself. Netherframe runs provider binaries locally (or in CI) and stores state in a backend you control—local file for sandboxes, S3 (--backend-type s3), or PostgreSQL graph state for concurrent team applies.
  2. Rollback scope: recovery_strategy="ROLLBACK" deletes every resource created by the failing apply and restores outputs referencing them; completed in-place updates or deletions cannot be inverted by Terraform providers and are explicitly reported. The default strategy (CHECKPOINT) preserves partial progress with a pre-apply snapshot.
  3. One graph across AWS and everything else: You can create an EKS cluster in AWS, configure the Kubernetes provider from its endpoint, and create namespaces or Helm releases in the same apply—no custom Lambda glue needed.

Migrating resources off CloudFormation safely

You do not need to recreate live AWS resources to move them from CloudFormation into Netherframe:

  1. Add DeletionPolicy: Retain to the target resources in your CloudFormation template and update the CloudFormation stack (or remove them from the template once Retain is active so CloudFormation detaches without deleting them).
  2. Model those resources in Netherframe with .import_from(physical_id) or LifecycleRules(adopt="required").
  3. Run nf plan --app <app> --diff --adopt-missing error --out adopt.plan.json, verify every resource shows as an import with zero unwanted replacements, and apply with nf apply --app <app> --plan-file adopt.plan.json.

Next steps