An opinionated starter kit by orangejellyfish for Serverless framework apps running in AWS. Built to be future-proof. Inspired by and adapted from the excellent serverless-babel-starter project by Postlight.
-
Lambdas run Node 18 by default making your functions faster and giving you the ability to use more recent ECMAScript features including async/await, optional chaining and nullish coalescing.
-
Lambda code is bundled with Webpack 5 via the serverless-webpack plugin, reducing the amount of code deployed to AWS. Source maps are generated and included in the bundle for easier debugging.
-
Lambda code is compiled with Babel 7 and babel-preset-env, meaning you can use even more cutting-edge ECMAScript features if you need to, without unnecessarily compiling code that would be supported by Node 16.
-
Lambda config is located alongside the function code and referenced from the top-level Serverless configuration file, offering greater separation of concerns and keeping the configuration file readable.
-
IAM roles are configured per-Lambda via the serverless-iam-roles-per-function plugin, meaning functions better follow the principle of least privilege and are therefore more secure.
-
API Gateway request logging into CloudWatch is enabled by default, meaning it will be easier to trace requests through the system, leading to more convenient debugging.
-
AWS X-Ray tracing is enabled for API Gateway and Lambda by default, giving greater visibility of the whole stack and making it easier to track down bottlenecks.
-
Opt-in to upcoming Serverless Framework features and changes to avoid seeing deprecation warnings on deployment.
-
CloudFormation stacks are split into nested stacks per Lambda function via the split-stacks plugin, helping to avoid the limit of 200 resources per stack.
-
A "run warm" utility which can be used as a higher order function by any Lambda function handler to keep the container alive, avoiding the cold start performance problem.
-
Jest support for unit testing, gathering coverage information by default.
-
ESLint, Husky and lint-staged config for greater code consistency.
-
Local AWS Lambda and API Gateway emulation via the serverless-offline plugin.
You can use the Serverless CLI to scaffold a new project from this starter kit:
serverless create --template-url https://github.com/orangejellyfish/serverless-starter --path your/local/path
WARNING: More than one matching handlers found for 'src/functions/hello/index'. Using 'src/functions/hello/index.js'.
This warning is logged by serverless-webpack when bundling the Lambda function code. It happens because the plugin detects another file in the same directory with a similar name. The other file is the unit test file. The warning can be safely ignored. See this issue for more information.