https://github.com/wingkwong/serverless-boilerplate
Serverless Boilerplate (APIGW + DynamoDB + Lambda)
https://github.com/wingkwong/serverless-boilerplate
api-gateway aws boilerplate dynamodb lambda serverless serverless-framework
Last synced: 4 months ago
JSON representation
Serverless Boilerplate (APIGW + DynamoDB + Lambda)
- Host: GitHub
- URL: https://github.com/wingkwong/serverless-boilerplate
- Owner: wingkwong
- Created: 2021-08-04T02:42:33.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2023-12-15T17:37:32.000Z (almost 2 years ago)
- Last Synced: 2025-04-12T19:18:54.641Z (6 months ago)
- Topics: api-gateway, aws, boilerplate, dynamodb, lambda, serverless, serverless-framework
- Language: JavaScript
- Homepage:
- Size: 123 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# serverless-boilerplate
Serverless Boilerplate (APIGW + DynamoDB + Lambda)
## Features
- Common packages for all APIs
- Define IAM roles pre function
- Package only dependencies it requires
- Preload environment variables into Serverless
- Separate backend resources and APIs## To-be-provisioned resources
- 1 API Gateway

- 1 DynamoDB with 2 Tables
- 2 Lambda functions

## Customize this boilerplate
- By default, this boilerplate uses ``foo`` and ``FOO`` as application name.
- By default, the fallback region is ``ap-southeast-1`` if you don't specify in ``.env``.
## Install
```
npm i serverless -g
```## Build backend resources (API Gateway + DynamoDB)
```
cd ./backend
npm i
```## Deploy backend resources (API Gateway + DynamoDB)
```
cd ./backend
sls deploy --stage='dev'
```
## Build API
```
cd api/src
npm i
```## Deploy API
There are two Lambda functions. Both will take the input fields (field1 and field2) and write to DynamoDB. The only difference is that api1 is integrated with SES and will send emails to notify specfic users. See [here](https://github.com/wingkwong/serverless-boilerplate/blob/master/api/src/api1/index.js#L72) for more.
```
cd api/src
sls deploy --stage='dev'
```
## Test API
> If you test api1, make sure your sender has been verified.
Headers
```
Content-Type:application/json
```Request Body
```
{
"field1": "foo",
"field2": "bar"
}
```Response

## Clean up
### Remove API
```
cd api/src
sls remove --stage='dev'
```### Remove backend resources (API Gateway + DynamoDB)
```
cd ./backend
sls remove --stage='dev'
```