Discussion

Testing Lambda function locally

Lambda-local lets you test NodeJS Amazon Lambda functions on your local machine, by providing a simplistic API and command-line tool.

npm install -g lambda-local

A simple way you can run lambda functions locally, without the need to create any special template files (like Serverless plugin and SAM requires), just adding the parameter --watch. It will raise a http server listening to the specified port (default is 8008), then you can pass the event payload to the handler via request body.

lambda-local -l examples/handler_helloworld.js -h handler --watch 8008
 
curl --request POST \
  --url http://localhost:8008/ \
  --header 'content-type: application/json' \
  --data '{
    "event": {
        "key1": "value1",
        "key2": "value2",
        "key3": "value3"
    }
}'

Here is the reference link for the package.

https://www.npmjs.com/package/lambda-local

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *