JSPM

serverless-offline-lambda

1.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2314
  • Score
    100M100P100Q121665F
  • License MIT

Emulate AWS λ Invocations locally when developing your Serverless project

Package Exports

  • serverless-offline-lambda

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (serverless-offline-lambda) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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();