Commandline tool to run Lambda functions on your local machine.
Lambda-local lets you test Amazon Lambda functions on your local machine with sample event data.
context of the Lambda function is already loaded so you do not have to worry about it.
You can pass any
event JSON object as you please.
npm install -g lambda-local
You can use Lambda-local as a command line tool.
# Usagelambda-local -l index.js -h handler -e event-samples/s3-put.js
You can also use Lambda local directly in a script. For instance, it is interesting in a MochaJS test suite in order to get test coverage.
See API for more infos
Event sample data are placed in
event-samples folder - feel free to use the files in here, or create your own event data.
Event data are just JSON objects exported:
// Sample event datamoduleexports =foo: "bar";
context object has been directly extracted from the source visible when running an actual Lambda function on AWS.
They may change the internals of this object, and Lambda-local does not guarantee that this will always be up-to-date with the actual context object.
Since the Amazon Lambda can load the AWS-SDK npm without installation, Lambda-local has also packaged AWS-SDK in its dependencies. If you want to use this, please use the "-p" option with the aws credentials file. More infos here: http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files
Executes a lambda given the
options object where keys are:
event- requested event as a json object
lambdaPath- requested path to the lambda function
lambdaFunc- pass the lambda function. You cannot use it at the same time as lambdaPath
profilePath- optional, path to your AWS credentials file
profileName- optional, aws profile name. Must be used with
lambdaHandler- optional handler name, default to
region- optional, AWS region, default to
callbackWaitsForEmptyEventLoop- optional, default to
true. Setting it to
falsewill call the callback when your code do, before finishing lambda-local
timeoutMs- optional, timeout, default to 3000 ms
environment- optional, extra environment variables for the lambda
mute- optional, allows to mute console.log calls in the lambda function, default false
callback- optional, lambda third parameter callback
If you are using winston, this pass a winston logger instead of the console.
This library is released under the MIT license.