Thinking of other ways how to deploy your full-stack web applications to AWS? Well, there is open-source framework that we can use to deploy web applications to AWS without ever touching the AWS Console because we know how easy it is to get lost in the number of services AWS offers but no worries! If you are a developer and prefers to have their whole Infrastructure as Code (IaC), worry no more because today we will be diving into one of the best tools that you can use. SST or Serverless Stack is an open-source framework that allows you to build your whole AWS Infrastructure as Code and provides a good automation for you to deploy any application that you wish. Ready to learn this Framework that enhances your AWS prowess? Let’s Go!
What is Serverless Stack? (SST)
Serverless Stack (SST) is an open-source framework that simplifies the deployment and management for serverless applications on AWS. It is built on top of the AWS CDK (Cloud Development Kit) but provides high-level abstractions, real-time debugging, and a seamless local development experience. With SST, developers can define infrastructure programmatically and deploy applications without manual intervention in the AWS Console.
Key Features of SST:
- Built on AWS CDK – Leverages the AWS CDK to define cloud resources using the programming language Typescript.
- Live Lambda Debugging – Allows developers to debug AWS Lambda functions in real-time using local development tools.
- Stacks and Constructs – Enables modular infrastructure that promotes scalability and maintainability.
Infrastructure as Code?
Infrastructure as Code (IaC) is one of the best practice when managing and provisioning cloud infrastructure using declarative code rather than manual process. IaC allows us to:
- Version Control Infrastructure – Treat infrastructure as code stored in Git repositories for collaboration and change tracking.
- Automate Deployments – Reduce human error by automating infrastructure provisioning and updates.
- Enhance Security and Compliance – Enforce security policies and best practices using automated configurations.
SST extends IaC principles by providing an abstraction layer over AWS CDK by simplifying the infrastructure definition process.
Setting Up Necessary Permission for SST
First thing to do is to setup the necessary permissions and policies for SST to use and be able to deploy any application we want.
Note: Make sure to replace the REGION
and ACCOUNT
and should be based on your AWS Account.
Tip: One of the best way to add this policy is to create an AWS Policy
and attach it to a IAM USER GROUP
then finally create an IAM USER
to be part of that group.
Next, is to setup our AWS Credentials
in our AWS ClI
:
- Download the official AWS CLI
- Create a new Access Key with IAM User you just created then download it
- Run this command and paste the correct values
aws configure --profile <profile-name>
AWS Access Key ID: <access-key>
AWS Secret Access Key: <secret-access-key>
Default region name: <your-preferred region>
Default output format: <your-preferred-format>
With that you have successfully setup the necessary permissions for SST to interact with your AWS Account and Resources.
Integrating SST to Your Project
SST supports many full-stack frameworks such as NextJS, Sveltekit, Analog, Nuxt, Remix, and many more! So I will leave that part for you to explore the in-depth guide per framework but for now I will give you the commands and how to configure sst for your application.
- Initialize SST to your project by running this command at the root of your project.
npx sst@latest init
. SST is smart enough to detect what framework you are using and accordingly use the best config for it. After, it will generate asst.config.ts
file.
SST Configuration File, here you can add another configurations like adding a DynamoDB table, RDS instance, VPC, and many more but for now a simple configuration to deploy a full-stack web application built for NextJS.
Commands to Test and Deploy
- Before running any command it will require to use the
AWS Profile
that we created earlier with the necessary permissions. We can do this simply by running theexport AWS_PROFILE=<your-created-aws-profile>
- To run a development instance locally, run this command:
npx sst dev
- To deploy your application, run this command
npx sst deploy --stage <stage-name>
Conclusion
Serverless Stack (SST) allows you to build fast and ship fast. It promotes great infrastructure management and deployment whilst being able to have fine-grained control. Also, it enhances developer productivity by providing a way for you to debug your application on a similar environment specially for Lambda powered applications. SST is an amazing tool make your AWS deployments easier!