11# Lambda-local
2- ============
32
43[ ![ Build Status] ( https://travis-ci.org/ashiina/lambda-local.svg?branch=develop )] ( https://travis-ci.org/ashiina/lambda-local )
54
65Lambda-local lets you test Amazon Lambda functions on your local machine with sample event data.
76The ` context ` of the Lambda function is already loaded so you do not have to worry about it.
87You can pass any ` event ` JSON object as you please.
98
10- ## As a command line tool
9+ ## Install
1110
12- You can use Lambda-local as a command line tool.
13-
14- # Install
15- ----
1611``` bash
1712npm install -g lambda-local
1813```
1914
15+ ## Usage
2016
21- # Usage
22- -----
17+ ### As a command line tool
18+
19+ You can use Lambda-local as a command line tool.
2320
2421``` bash
2522# Usage
2623lambda-local -l index.js -h handler -e event-samples/s3-put.js
2724```
2825
29- # About
30- -----
26+ ### In another node.js script
27+
28+ You can also use Lambda local directly in a script. For instance, it is interesting in a [ mocha] [ 1 ] test suite in combination with [ istanbull] [ 2 ] in order to get test coverage.
29+
30+ ``` js
31+ const lambdaLocal = require (' lambda-local' );
32+
33+ var jsonPayload = {
34+ ' key1' : ' value1' ,
35+ ' key2' : ' value2' ,
36+ ' key3' : ' value3'
37+ }
38+
39+ lambdaLocal .execute ({
40+ event : jsonPayload,
41+ lambdaPath: path .join (__dirname , ' path/to/index.js' ),
42+ profilePath: ' ~/.aws/credentials' ,
43+ profileName: ' default' ,
44+ timeoutMs: 3000 ,
45+ callback : function (err , data ) {
46+ if (err) {
47+ console .log (err);
48+ } else {
49+ console .log (data);
50+ }
51+ }
52+ });
53+ ```
54+
55+ ## About
56+
3157### Command
3258* -l, --lambda-path <lambda index path > (required) Specify Lambda function file name.
3359* -e, --event-path <event path > (required) Specify event data file name.
@@ -57,37 +83,6 @@ Since the Amazon Lambda can load the AWS-SDK npm without installation, Lambda-lo
5783If you want to use this, please use the "-p" option with the aws credentials file. More infos here:
5884http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-config-files
5985
60- # In another node.js script
61-
62- You can also use Lambda local directly in a script. For instance, it is interesting in a [ mocha] [ 1 ] test suite in combination with [ istanbull] [ 2 ] in order to get test coverage.
63-
64- ## Usage
65-
66- ``` js
67- const lambdaLocal = require (' lambda-local' );
68-
69- var jsonPayload = {
70- ' key1' : ' value1' ,
71- ' key2' : ' value2' ,
72- ' key3' : ' value3'
73- }
74-
75- lambdaLocal .execute ({
76- event : jsonPayload,
77- lambdaPath: path .join (__dirname , ' path/to/index.js' ),
78- profilePath: ' ~/.aws/credentials' ,
79- profileName: ' default' ,
80- timeoutMs: 3000 ,
81- callback : function (err , data ) {
82- if (err) {
83- console .log (err);
84- } else {
85- console .log (data);
86- }
87- }
88- });
89- ```
90-
9186## API
9287
9388### LambdLocal
@@ -106,8 +101,8 @@ Executes a lambda given the `options` object where keys are:
106101- ` mute ` - optional, allows to mute console.log calls in the lambda function, default false
107102- ` callback ` - optional lambda third parameter [ callback] [ 3 ]
108103
109- # License
110- ----------
104+ ## License
105+
111106This library is released under the MIT license.
112107
113108[ 1 ] : https://mochajs.org/
0 commit comments