1.0.6 • Published 5 years ago

serverless-offline-lambda v1.0.6

Weekly downloads
6,777
License
MIT
Repository
github
Last release
5 years ago

serverless-offline-lambda

This Serverless plugin extends serverless-offline to emulates AWS λ Invocations on your local machine to speed up your development cycles. To do so, it starts an HTTP server to invoke a Lambda using the AWS SDK.

Installation

First, add Serverless Plugin to your project:

npm install serverless-offline-lambda --save-dev

Then inside your project's serverless.yml file add following entry to the plugins section: serverless-offline-lamda. If there is no plugin section you will need to add it to the file.

It should look something like this:

plugins:
  - serverless-offline-lambda
  - serverless-offline

Example

Run Serverless Offline

sls offline start

Invoke Lambda using AWS SDK.

const AWS = require('aws-sdk');

const lambda = new AWS.Lambda({
  endpoint: new AWS.Endpoint('http://localhost:4000'),
  region: 'us-east-1',
});


lambda.invoke({
  FunctionName: 'function',
  InvocationType: 'Event',
  Payload: JSON.stringify({ key: 'value' }),
}).promise();

Config

By default the Lambda endpoint listens on localhost port 4000, but this can be changed in serverless.yml:

custom:
  lambda:
    host: 0.0.0.0
    port: 1234
1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago