Getting Started with the Serverless Stack (SST) Framework

satish1v
AWS in Plain English
3 min readOct 11, 2021

--

Photo by Jordan Harrison on Unsplash

Serverless platforms allow you to experiment with ideas faster. Faster development of features has attracted many audiences to use Serverless for development, but it lacks a guide for doing that when it comes to productizing.

In this blog series, I will show how to build a production-grade Serverless application that automates the

  1. Infrastructure using AWS CDK,
  2. Apply user and API level using Cognito
  3. Debugging with Lambda Dev environment
  4. CI/CD with different environment
  5. Hosting React application
  6. Adding Custom domain for the application
  7. Observability using Cloud Watch.

It may look like a lot, but it's easy to build on top of each other. An excellent framework called Serverless stack has made this possible.

Installation:

Serverless is a collection of Node NPM packages, and that allows you to create a package.

You can download and install in case if you don't already have the same.

I use VScode for most of my development, and you can download it from

Configure AWS Account:

You should configure your machine with aws access for the deploy and testing. You can do that using the following blog post.

Installing Serverless Stack

Once downloaded, you can now install the SST from the command line using

npx create-serverless-stack@latest todo

npx command will create a folder with relevant folders.

todo├── README.md├── node_modules├── .gitignore├── package.json├── sst.json├── test│   └── MyStack.test.js├── stacks|   ├── MyStack.js|   └── index.js└── src└── lambda.js

An SST app contains a couple of parts.

  • stacks/ — App Infrastructure. This folder contains the Infrastructure code. SST uses AWS CDK to create the infrastructure.
  • src/ — App Code. These are your Lambda functions.
  • test/ — Unit tests. There's also a test/ directory where you can add your tests. SST uses Jest internally to run your tests.

You can change this structure around to fit your workflow.

You can run the application using the following command from the root dir

npx sst start

The first time you run the command, it may take few seconds and provide you with the URL like

The ApiEndpoint contains the URL for the hosted lambda service.

Well, in the next blog. I will start with the simple to-do application and create a complete app with all the production-grade features.

Next Blog Post

https://satish1v.medium.com/production-ready-serverless-application-architecture-5751f0f7ec6e

More content at plainenglish.io

--

--