Serverless Boilerplate - Generic boilerplate for developing applications using the Serverless Framework.
- Installation
- Usage and command line options
- Debug process
- Todo
- Notes
- Credits and inspiration
- Contributing
- License
Generate a key: aws kms create-key
and get the keyId
.
Encrypt a variable with
serverless encrypt --name foo --value bar --keyid {keyId}
This boilerplate includes two options for running DynamoDB: the JVM-based AWS version and Dynalite, a Node-based version of DynamoDB
DynamoDB will be installed locally and automatically though the install:dynamodb
script in package.json
, i.e., yarn install:dynamodb
. For the JVM-based version you need to enable to following plugin in your plugins section:
plugins:
- serverless-webpack
- serverless-dynamodb-local
- serverless-offline
Note that it comes after the serverless-webpack
plugin and before the serverless-offline
plugin.
This configuration in serverless.yml
starts DynamoDB automatically when the local server is started with yarn start
or serverless offline start
.
custom:
dynamodb:
start:
port: 8000
inMemory: true
migrate: true
seed: true
You can access the shell interface to interact with DynamoDB at http://localhost:8000/shell
.
This plugin can be found in the .serverless_plugins
directory in the root of this boilerplate. I didn't include the official plugin because it does not work with serverless-offline
and you would need to start it separately.
If you want to use Dynalite instead, you need to enable it before serverless-webpack
plugin, for example:
plugins:
- serverless-dynalite
- serverless-webpack
- serverless-offline
An admin interface for DynamoDB can be started with yarn dynamodb:admin
, and will be available on http://localhost:8001
.
Using the serverless-domain-manager
plugin you can easily map your serverless application to a particular domain name.
To create the custom domain:
serverless create_domain
To deploy with the custom domain:
severless deploy
To remove the created custom domain:
serverless delete_domain
This boilerplate contains the following plugins:
-
Serverless Offline Plugin: Emulates AWS λ and API Gateway on your local machine to speed up your development cycles.
-
Serverless Webpack: A Serverless v1.x plugin to build your lambda functions with Webpack.
-
Serverless KMS Secrets: A Serverless Plugin which helps with encrypting service secrets using the AWS Key Management Service (KMS).
-
Serverless Jest Plugin: plugin to enable test driven development using jest, and adding functionality to create functions and tests from command line
-
Serverless AWS Documentation: Plugin that adds support for AWS API Gateway documentation and models (e.g. to export a Swagger JSON file with input/output definitions and full text documentation for API documentation).
-
Serverless DynamoDB Local: Allows to run dynamodb locally for serverless.
-
Serverless Domain Manager: Create custom domain names that your lambda can deploy to with serverless. Allows for base path mapping when deploying and deletion of domain names.
-
Serverless VPC Discovery: The vpc discovery plugin takes the given vpc, subnet, and security group names in the serverless file to setup the vpc configuration for the lambda.
-
file
serverless.yml.json
: Register plugins above -
file
webpack.config.js
: Settings for webpack-plugin -
file
templates/function.ejs
: Template to use for new functions
- API logs
- Hooks
- Build plugin
- Containerization with Docker
- Shell
- ??
- Test framework (jest)
Gulp with watch and eslintKMS secretsQuality check with CodeClimateConfiguration managementAutomatic AWS DocumentationCoverage check with CodecovDynamoDB and DynaliteDomain Name ManagerVPC Discovery
Need to write more details
Command yarn release
.
The jest plugin seems to have several issues, such as:
- it doesn't respect a custom template for tests,
- when an error occurs while creating a function and test it still updates the
serverless.yml
file but does not create the function and test file, - running
serverless invoke test --function foo
only works when the handler defined in the function ofserverless.yml
matches the test name.
Yes, thank you! This boilerplate is community-driven, most of its features are from different authors. Please update the docs and tests and add your name to the package.json file. We try to follow Airbnb's JavaScript Style Guide.