What is sst?
The SST (Serverless Stack Toolkit) npm package is a framework for building serverless applications. It provides a set of tools and abstractions to simplify the development, deployment, and management of serverless applications on AWS. SST supports various AWS services and allows developers to define their infrastructure as code using AWS CDK (Cloud Development Kit).
What are sst's main functionalities?
Define Infrastructure
This feature allows you to define your cloud infrastructure using SST. In this example, an S3 bucket is created within a stack.
const sst = require('@serverless-stack/resources');
class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Define an S3 bucket
const bucket = new sst.Bucket(this, 'MyBucket');
}
}
module.exports = function main(app) {
new MyStack(app, 'my-stack');
};
Deploy Lambda Functions
This feature allows you to deploy AWS Lambda functions easily. In this example, a Lambda function is defined with a handler located at 'src/lambda.handler'.
const sst = require('@serverless-stack/resources');
class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Define a Lambda function
const lambda = new sst.Function(this, 'MyFunction', {
handler: 'src/lambda.handler',
});
}
}
module.exports = function main(app) {
new MyStack(app, 'my-stack');
};
API Gateway Integration
This feature allows you to integrate API Gateway with your Lambda functions. In this example, an API Gateway is created with a route that triggers the Lambda function defined at 'src/lambda.handler'.
const sst = require('@serverless-stack/resources');
class MyStack extends sst.Stack {
constructor(scope, id, props) {
super(scope, id, props);
// Define an API Gateway
const api = new sst.Api(this, 'Api', {
routes: {
'GET /': 'src/lambda.handler',
},
});
}
}
module.exports = function main(app) {
new MyStack(app, 'my-stack');
};
Other packages similar to sst
serverless
The Serverless Framework is a popular open-source framework for building and deploying serverless applications. It supports multiple cloud providers, including AWS, Azure, and Google Cloud. Compared to SST, Serverless Framework offers a more extensive plugin ecosystem and broader cloud provider support, but SST provides tighter integration with AWS CDK.
aws-cdk
The AWS Cloud Development Kit (CDK) is a framework for defining cloud infrastructure using familiar programming languages. It allows developers to define their infrastructure as code and provides high-level constructs for AWS services. While SST uses AWS CDK under the hood, it adds additional abstractions and tools specifically for serverless applications, making it easier to work with serverless architectures.
pulumi
Pulumi is an infrastructure as code tool that allows developers to define cloud resources using general-purpose programming languages. It supports multiple cloud providers and offers a flexible and modern approach to infrastructure management. Compared to SST, Pulumi provides broader cloud provider support and language flexibility, but SST offers a more focused experience for AWS serverless applications.
sst
SST makes it easy to build modern full-stack applications on AWS.
The sst
package is made up of the following.
Installation
Install the sst
package in your project root.
npm install sst --save-exact
Usage
Once installed, you can run the CLI commands using.
npx sst <command>
Import the Node.js client in your functions. For example, you can import the Bucket
client.
import { Bucket } from "sst/node/bucket";
And import the constructs you need in your stacks code. For example, you can add an API.
import { Api } from "sst/constructs";
For more details, head over to our docs.
Join our community Discord | YouTube | Twitter