deeheber / note-service

Serverless microservice CRUD demo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

note-service

A serverless CRUD REST API for demo purposes powered by AWS SAM, API Gateway (HTTP API), Lambda Functions (node runtime), and DynamoDB

Architecture

note-api

Routes

  • GET /note - list all notes (using DDB scan for demo purposes, but you'd probably want to use query and paginate the results as this can be costly with a large table)
  • GET /note/{ id } - get a single note by id
  • POST /note - create note with author and content
  • PUT /note/{ id } - update a note's content
  • DELETE /note/{ id } - delete a note by id

Additional

  • Deploy this stack to your AWS account using the AWS SAM CLI
    • sam build
    • sam deploy --guided
  • This is using the HTTP protocol of API Gateway, the statusCode and headers are optional in the Lambda responses.
  • Make sure to configure your CORS settings in template.yaml if you want this to interact with a web frontend. It should work out of the box with curl or Postman
  • Be careful keeping this deployed on the wide open internet since the API is not secured. I.e. someone could find this URL and hit it a lot of times resulting in a large AWS bill for you. See this guide for more info on securing an API. I'd think the IAM authorizer is probably easiest for dev purposes if this is a concern for you.
  • There are ways to do a direct http api <=> dynamoDB integration, but I wanted to show how to use Lambda functions to interact with DynamoDB. For minimal CRUD operations like this, you'd probably want go the direct integration path to save some money.

About

Serverless microservice CRUD demo


Languages

Language:JavaScript 100.0%