Skip to content

cliffom/sst-bff-demo

Repository files navigation

sst-bff-demo lint-and-test deploy

A demonstration of how to use SST to build and deploy a GraphQL endpoint with backing services written in Go.

This project was bootstrapped with Create Serverless Stack.

Start by installing the dependencies.

$ yarn install

What this is

A sample application demonstrating how to build different services deployed as Lambda functions.

Here we build and deploy 4 Lambda functions:

  • One Lambda function with the NodeJS runtime for Apollo Server (Apollo Stack)
  • One Lambda function with the Go runtime for user services (Users API Stack)
  • One Lambda function with the Go runtime for user tasks (User Tasks Stack)
  • One Lambda function with the Go runtime as a test route (API Stack)

Though the API Gateways fronting Apollo Server and API stacks are accessible individually, here we are demonstrating using the RESTful API stack as a datasource for the Apollo Server.

The routes exposed by the API Stack are protected with a Cognito Pool (created within the stack) and require a valid JWT token. The GraphQL route is open to the public but passes the authorization header to the API endpoints.

To demonstrate connection to a DynamoDB table from the RESTful services, a DynamoDB table is created and accessible by the API stack.

Example Request Path:

User->API Gateway->Apollo Stack->API Gateway->API Stack

Commands

yarn run start

Starts the local Lambda development environment.

yarn run build

Build your app and synthesize your stacks.

Generates a .build/ directory with the compiled files and a .build/cdk.out/ directory with the synthesized CloudFormation stacks.

yarn run deploy [stack]

Deploy all your stacks to AWS. Or optionally deploy a specific stack.

yarn run remove [stack]

Remove all your stacks and all of their resources from AWS. Or optionally remove a specific stack.

yarn run test

Runs your tests using Jest. Takes all the Jest CLI options.

Cognito

Use the following commands to create, verify, and authenticate a user in Cognito

# Create and verify a user in Cognito
make create-user CLIENT_ID=$CLIENT_ID USER_POOL_ID=$USER_POOL_ID EMAIL=$EMAIL PASSWORD=$PASSWORD

# Authenticate a user and get the required token
make user-token CLIENT_ID=$CLIENT_ID EMAIL=$EMAIL PASSWORD=$PASSWORD

Documentation

Learn more about the Serverless Stack.

Community

Follow us on Twitter or post on our forums.

About

A demonstration of how to use SST to build and deploy a GraphQL endpoint with backing services written in Go.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published