Giter Site home page Giter Site logo

sst-template's Introduction

SST production-ready template

This is built using SST.

This includes everything needed to:

  • Deploy a web frontend and backend with NextJS
  • Deploy lambda functions with or without api gatway that can be called via HTTPS, cron, another lambda function or NextJS (ssr functions, react server components or api routes)
  • Deploy long running dockerized jobs and invoke from NextJS, lambda or cron
  • Anything else SST supports like Event Bus, Database, Message Queues, etc...

Everything is deployed to AWS. All infrastructure configuration is done in code in this repo.

Instructions assume you are using yarn

Template Examples

  • Next JS site (/app)
  • API route using a lambda function (/functions/testApi.ts)
  • Lambda function which can be invoked directly (/functions/testFunction.ts)
  • Long running job using built-in node container (/jobs/testJob.ts)
  • Long running job in python using a Dockerfile (/jobs/pythonContainerJob)
  • Cron job (commented out in sst.config.ts)

Run Development

yarn dev

This will run dev:sst and dev:next using concurrently. You can also run these independently if you want them in separate terminal windows.

SST will provide a web console url when started for getting URLs to endpoints, invoking lambda functions, testing apis, running sql queries on rds, etc...

Front end will be running locally

SST will provide dev URLs in the terminal and in the console

Deploy to Production

yarn deploy

Initial Setup

Install Required Software

  • Homebrew, if you need to install any of the packages below. Requires XCode & XCode command line tools.
  • node (brew install node@18)
  • nvm (optional, manages node versions: brew install nvm)
  • yarn (optional, npm i -g yarn)
  • awscli (brew install awscli)
  • docker (required if you need to use long running dockerized jobs, brew install docker)
  • this repo (git clone [url of this repo])

Install node packages

  • If using nvm run nvm use in the root to use lts/hydrogen (v18). You may need to install first using nvm install lts/hydrogen
  • Run yarn in the root of the repo to install package dependencies

Set up AWS

Your AWS credentials should be in the local environment. If not, use aws configure

Setup SST

Run yarn dev:sst.

The first time you run it, SST will deploy a dev environment and will prompt for a name for your personal dev environment. You should use your name instead of something like "dev" to avoid conflicting with anyone else doing development on the same repo.

New Project

For a new project check the project name and aws region at the top of sst.config.ts

Adding new services

Example service configurations are in sst.config.ts. Creating a new service generally involves simply adding resource files and adding a configuration to sst.config.ts.

For example, to create a new Lambda function with an api gateway wrapper:

  • Create a file with a lambda handler in /functions
  • Add a service configuration in sst.config.ts using the Api construct
  • Add a bind entry where needed to give other services access to the new service

Next JS Template

The Next JS template is pre-configured with:

  • App folder (supports react server components)
  • Typescript
  • Tailwindcss
  • Shadcn UI - Radix Components styled with Tailwindcss

sst-template's People

Watchers

Kai Yen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.