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
$ npm install --global gulp-cli
- Download AWSLambdaJS via Git.
$ git clone https://github.com/roman-zaglauer/AWSLambdaJS.git
- 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
- Start your project Set up necessary credentials and information for the AWS Lambda Function by this command:
$ gulp init
- Now the project is ready to start.
or
-
Create an empty folder where your project lives.
-
Open a command prompt inside this project folder.
-
Extract the content of master.zip into your project folder.
-
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
- Start your project Set up necessary credentials and information for the AWS Lambda Function by this command:
$ gulp init
- Now the project is ready to start.
$ gulp <task>
init
Set necessary credentials and information for the AWS Lambda Functioncredentials:init
Set the credentials- AccessKey ID
- SecretAccessKey
- Region
parameter:init
Set the parameters of the AWS Lambda Function- Function Name
- Handler
- Role
- Runtime
- Description
- MemorySize
- Timeout
- Publish
- S3Bucket
- 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.
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.
Initial release
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.