1.3.9 • Published 5 years ago

generator-serverless-scaffolder v1.3.9

Weekly downloads
9
License
Apache-2.0
Repository
github
Last release
5 years ago

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-scaffolder

Move into the directory you wish to create your app in (e.g. projects/) and run the generator:

yo serverless-scaffolder

If you want to generate the project with full CodeBuild / CodePipeline and Lambda Terraform IAC then run with the --iac flag.

yo serverless-scaffolder --iac

Answer 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:service

This 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:util

This 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:constants

This 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:error

This 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:iac

This 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-ci

All 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-lambda

All 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-apigateway

All code will be generated in iac/apigateway

License

Apache-2.0 © Blair Calderwood

Contributors

Blair CalderwoodBlair CalderwoodMatt ChildsMatt ChildsJames WoolfendenJames Woolfenden
1.3.6

5 years ago

1.4.0

5 years ago

1.3.9

5 years ago

1.3.5

5 years ago

1.3.4

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.12

5 years ago

1.2.8

5 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago