Chris Straw

Let’s talk about SST for building out AWS infrastructure as code

AWS Serverless Stack Toolkit, or SST, is a framework for building serverless applications in AWS. It is built on top of AWS CDK (Cloud Development Kit), which is a powerful open-source software development framework to define cloud infrastructure in code and provision it through AWS CloudFormation.

With AWS CDK, you can design your cloud resources using familiar programming languages such as TypeScript, Python, Java, and C#. It essentially enables developers to leverage the expressiveness of their preferred language to define AWS resources in a predictable and efficient manner.

SST extends AWS CDK’s capabilities to include features specifically designed for serverless applications, such as:

  1. Fast deployments: SST uses AWS CDK under the hood but it’s optimized for serverless applications, so it only deploys the necessary changes.
  2. Live Lambda development: With SST, you can work on your Lambdas and see your changes live. This is a major boost to development speed.
  3. Secure: SST sets up a secure environment with best practices by default. It handles all the security configurations for you.
  4. ESBuild and TypeScript support: SST uses ESBuild to bundle your AWS Lambda functions, allowing you to write your serverless functions in TypeScript (or JavaScript). ESBuild is extremely fast and provides a major speed boost to your build process.

Here is an example of how you can define a serverless stack using SST with TypeScript:

import * as sst from "@serverless-stack/resources";

class MyStack extends sst.Stack {
  constructor(scope: sst.App, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    // Create a HTTP API
    const api = new sst.Api(this, "Api", {
      routes: {
        "GET /": "src/lambda.handler",

    // Show the API endpoint in the output
      "ApiEndpoint": api.url,

export default function main(app: sst.App): void {
  new MyStack(app, "my-stack");

In the example above, we define a serverless stack that includes a single API Gateway with a Lambda function. The handler of the function is defined in “src/lambda.handler”. SST will automatically set up the routing and permissions for you.

Please note that, as of my last update in September 2021, AWS CDK itself has also started introducing more serverless specific features, and many libraries have been developed on top of it to make building serverless applications easier. Always make sure to keep up-to-date with the latest AWS services and features.