generator-serverless-scaffolder v1.3.9
Serverless Scaffolder
The Serverless Scaffolder is a highly opinionated AWS Lambda generator built using the Yeoman scaffolding tool. This tool is fantastic for spinning up new Lambda projects very quickly and so works well in conjunction with a microservices based architecture.
Getting Started
Install Yeoman and the scaffolder via npm:
npm install -g yo
npm install -g generator-serverless-scaffolderMove into the directory you wish to create your app in (e.g. projects/) and run the generator:
yo serverless-scaffolderIf you want to generate the project with full CodeBuild / CodePipeline and Lambda Terraform IAC then run with the --iac flag.
yo serverless-scaffolder --iacAnswer the questions when prompted. The app will now be generated with everything you need to start a Lambda based project.
What is generated?
- src folder with index.js and Lambda entry point function
- Linter with opinionated linting rules
- .gitignore file which includes files you will typically want to keep out of your git repository
- .nvmrc which locks the Lambda to Node version 10.14.1. This can be changed if needed. To use the version included here install nvm and run
nvm use - Pre-commit rules which (among other things) ensures AWS keys are not accidentally posted to a git repository (pre-commit will need to be installed for this to work)
- The Jest testing suite to unit test code
- A package.json file with all the necessarry npm installs and commands to get you started developing Lambda functions
- A Readme with all the information you'll need to get started
Subgenerators
Service
To generate a new service in the src/services folder of your generated project run
yo serverless-scaffolder:serviceThis will create a new service class and Jest test file to unit test the aforementioned class.
Util
To generate a new set of utils in the src/utils folder of your generated project run
yo serverless-scaffolder:utilThis will create a new util file and Jest test file to unit test the aforementioned functions.
Constants
To generate a new constants file in the src/constants folder of your generated project run
yo serverless-scaffolder:constantsThis will create a new constants file.
Errors
To generate a new error type file in the src/errors folder of your generated project run
yo serverless-scaffolder:errorThis will create a new error class which can then be imported and thrown in any project JavaScript file.
Infrastructure As Code
To generate all Terraform associated with standing up CodeBuild/CodePipeline and Lambda for a dev/test environment the following should be run from the root directory
yo serverless-scaffolder:iacThis will create all of the associated IAC in the iac/ folder. If only the CI or the Lambda IAC is needed please run one of the subcommands found below.
Infrastructure As Code - CI (iac-ci)
To generate all associated Terraform to standup CodeBuild/CodePipeline for a dev/test environment located in iac/. This should be run from the root folder of your generated project.
yo serverless-scaffolder:iac-ciAll code will be generated in iac/.
Infrastructure As Code - Lambda (iac-lambda)
To generate all associated Terraform to standup lambda infrastructure for a dev/test environment. This should be run from the root folder of your generated project.
yo serverless-scaffolder:iac-lambdaAll code will be generated in iac/lambda
Infrastructure As Code - API Gateway (iac-apigateway)
To generate all associated Terraform to standup API Gateway infrastructure for a dev/test environment. This should be run from the root folder of your generated project. The terraform should be ran after the Lambda terraform, as it depends on a lambda function being deployed in the same AWS account.
yo serverless-scaffolder:iac-apigatewayAll code will be generated in iac/apigateway
License
Apache-2.0 © Blair Calderwood
Contributors
Blair Calderwood | Matt Childs | James Woolfenden |
|---|
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago


