Building a CDK app with SST
We are going to be using AWS CDK to create and deploy the infrastructure our Serverless app is going to need. We are using Serverless Framework for our APIs. And to use CDK with it, we’ll be using the Serverless Stack Toolkit (SST). It’s an extension of CDK that allows us to deploy it alongside our Serverless Framework service.
Let’s get started.
Create a new SST app
In the root of your Serverless app run the following.
$ npx create-serverless-stack resources infrastructure
This will create your SST app in the infrastructure/
directory inside your Serverless project.
Now let’s go in there and do a quick build.
$ cd infrastructure
$ npx sst build
You should see something like this.
Successfully compiled 1 stack to build/cdk.out:
dev-infrastructure-my-stack
There are template files created for us to use. We’ll be overwriting them in the next chapter.
Update your config
Let’s also quickly change the config a bit. It has your app name, the default stage and region we are deploying to.
Replace your infrastructure/sst.json
with.
{
"name": "notes-infra",
"type": "@serverless-stack/resources",
"stage": "dev",
"region": "us-east-1"
}
Now we are ready to configure our infrastructure. We’ll look at DynamoDB first.
For help and discussion
Comments on this chapter