Skip to main content

Migrating From CDK

A guide to migrating your CDK app to SST.


SST is an extension of AWS CDK. It's fairly simple to move a CDK app to SST. You just need to account for a couple of small differences:

  1. There is no cdk.json

    If you have a context block in your cdk.json, you can move it to a cdk.context.json. You can read more about this here. You'll also need to add a sst.json config file, as talked about here. Here is a sample config for reference.

    {
    "name": "my-sst-app",
    "stage": "dev",
    "region": "us-east-1"
    }
  2. There is no bin/*.js

    Instead there is a stacks/index.js that has a default export function where you can add your stacks. SST creates the App object for you. This is what allows SST to ensure that the stage, region, and AWS accounts are set uniformly across all the stacks. Here is a sample stacks/index.js for reference.

    import MyStack from "./MyStack";

    export default function main(app) {
    new MyStack(app, "my-stack");

    // Add more stacks
    }
  3. Stacks are written as functions

    Your classes are written as functions instead of cdk.Stack. Here is what the JavaScript version looks like.

    import * as sst from "sst/constructs";

    export function MyStack(ctx) {}

    And in TypeScript.

    import * as sst from "sst/constructs";

    export function MyStack(ctx: sst.StackContext) {}
  4. Lambdas use sst.Function

    Use the sst.Function construct instead of cdk.lambda.NodejsFunction.

  5. Include the right packages

    You don't need the aws-cdk package in your package.json. Instead you'll need sst package.