Skip to content

AWSLambdaJS is a NodeJS programming template for AWS Lambda Functions

License

Notifications You must be signed in to change notification settings

roman-zaglauer/AWSLambdaJS

Repository files navigation

AWSLambdaJS an AWS Lambda Function Template

Version 0.1.0

Abstract

This is a NodeJS programming template for AWS Lambda Functions called AWSLambdaJS. It should help and support to develop AWS Lambad Function by providing the most common tasks to do so. AWSLambdaJS helps to get rid of the manual labor and repeating project setup task in order to focus on the AWS Lambda Function instead.

It uses the taskrunner Gulp with fully configured and ready to use tasks.

Provided by Roman Zaglauer

Installation

One-time tasks

  1. Install Git from the Git

  2. Install NodeJS from the NodeJS

  3. Install Gulp via npm

$ npm install --global gulp-cli

Tasks to be done for each project

  1. Download AWSLambdaJS via Git.
$ git clone https://github.com/roman-zaglauer/AWSLambdaJS.git
  1. Install all dependencies needed for AWSLambdaJS.
    This can take some time. The command can only by executed if you perform it inside the directory.
$ npm install
  1. Start your project Set up necessary credentials and information for the AWS Lambda Function by this command:
$ gulp init
  1. Now the project is ready to start.

or

  1. Create an empty folder where your project lives.

  2. Open a command prompt inside this project folder.

  3. Extract the content of master.zip into your project folder.

  4. Install all dependencies needed for AWSLambdaJS This can take some time. The command can only executed if you perform it inside the directory.

$ npm install
  1. Start your project Set up necessary credentials and information for the AWS Lambda Function by this command:
$ gulp init
  1. Now the project is ready to start.

Usage

Gulp Tasks

$ gulp <task>
  • init
    Set necessary credentials and information for the AWS Lambda Function
    • credentials:init
      Set the credentials
      1. AccessKey ID
      2. SecretAccessKey
      3. Region
    • parameter:init Set the parameters of the AWS Lambda Function
      1. Function Name
      2. Handler
      3. Role
      4. Runtime
      5. Description
      6. MemorySize
      7. Timeout
      8. Publish
      9. S3Bucket
      10. S3Key
  • lint
    Show if there are any ESLint errors (target directory ./src/).
    • watch:lint
      Run ESLint watch task. Every save triggers ESLint checks.
  • test
    Run unit test using the JavaScript test framework Mocha (source directory ./test/unit) (target directory ./src/).
    • watch:test
      Run Mocha watch task. Every save triggers the execution of the defined tests.
  • invoke
    Calls the lambda function with an event (./test/event.json). Can be used for debugging.
  • doc
    Creates documentation using JSDoc3 (source directory ./src/unit) (target directory ./doc/)
    • clean:doc
      Cleanup ./doc/ directory.
    • jsdoc:doc
      Run JSDoc3 to create documentation.
    • zip:doc
      Archive the created documentation files.
  • build
    Build the files ready for uploading to AWS Lambda (source directory ./src/) (target directory ./dist/).
    • lint:build
      Show if there are any ESLint errors.
    • clean:build
      Cleanup ./dist/ directory.
    • install:build
      Install all dependencies (no development dependencies) to ./dist/ directory.
    • beautify:build
      Copy and beautify all files from ./src/ to ./dist/ directory.
    • uglify:build
      Copy and uglify all *.js files from ./src/ to ./dist/ directory renaming them to *.min.js.
    • zip:build
      Archive the created build filles.
  • upload
    Upload the files to AWS Lambda.
  • deploy
    Deploy the files to AWS Lambda (source directory ./src/) (target directory ./dist/).
    • lint:deploy
      Show if there are any ESLint errors.
    • clean:deploy
      Cleanup ./dist/ directory.
    • install:deploy
      Install all dependencies (no development dependencies) to ./dist/ directory.
    • beautify:deploy
      Copy and beautify all files from ./src/ to ./dist/ directory.
    • uglify:deploy
      Copy and uglify all *.js files from src/ to ./dist/ directory renaming them to *.min.js.
    • zip:deploy
      Archive the created build filles.
    • upload:deploy
      Upload the files to AWS Lambda.
  • beautify
    Copy and beautify all files from ./src/ to ./dist/ directory.
  • uglify
    Copy and uglify all *.js files from ./src/ to ./dist/ directory renaming them to *.min.js.
  • zip
    Archive the build filles.

Notes

Test

The test folder already contains a sample test setup to perform unit a tests by using Mocha. To add new tests you have to add your test into the directory ./test/unit/. The test will be considered automatically.

Release History

0.1.0

Initial release

License

MIT License

Copyright (c) 2019 Roman Zaglauer

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

AWSLambdaJS is a NodeJS programming template for AWS Lambda Functions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published