Create an SST app
Now that we understand what infrastructure as code is, we are ready to create our first SST app.
Run the following in your working directory.
$ pnpm create sst notes
$ cd notes
$ pnpm install
By default, our app will be deployed to the us-east-1
AWS region. This can be changed in the sst.config.ts
in your project root.
import { SSTConfig } from "sst";
import { API } from "./stacks/MyStack";
export default {
config(_input) {
return {
name: "notes",
region: "us-east-1",
};
},
stacks(app) {
app.stack(API);
},
} satisfies SSTConfig;
Project layout
An SST app is made up of two parts.
-
stacks/
— App InfrastructureThe code that describes the infrastructure of your serverless app is placed in the
stacks/
directory of your project. SST uses AWS CDK, to create the infrastructure. -
packages/
— App CodeThe Lambda function code that’s run when your API is invoked is placed in the
packages/functions
directory of your project. Whilepackages/core
contains our business logic.
Our app is structured as a monorepo. Later on we’ll be adding a frontend/
directory for our React app.
The starter project that’s created is defining a simple Hello World API. In the next chapter, we’ll be deploying it and running it locally.
For help and discussion
Comments on this chapter