https://github.com/marconi1992/serverless-offline-lambda
Emulate AWS λ Invocations locally when developing your Serverless project
https://github.com/marconi1992/serverless-offline-lambda
lambda serverless serverless-offline
Last synced: 7 months ago
JSON representation
Emulate AWS λ Invocations locally when developing your Serverless project
- Host: GitHub
- URL: https://github.com/marconi1992/serverless-offline-lambda
- Owner: marconi1992
- License: mit
- Created: 2019-01-31T06:07:12.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-12-18T17:05:18.000Z (over 5 years ago)
- Last Synced: 2025-07-06T21:59:29.964Z (9 months ago)
- Topics: lambda, serverless, serverless-offline
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/serverless-offline-lambda
- Size: 45.9 KB
- Stars: 10
- Watchers: 2
- Forks: 10
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# serverless-offline-lambda
This [Serverless](https://github.com/serverless/serverless) plugin extends [serverless-offline](https://github.com/dherault/serverless-offline) to emulates [AWS λ](https://aws.amazon.com/lambda) 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](https://github.com/aws/aws-sdk-js).
## 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:
```YAML
plugins:
- serverless-offline-lambda
- serverless-offline
```
## Example
Run Serverless Offline
```
sls offline start
```
Invoke Lambda using [AWS SDK](https://github.com/aws/aws-sdk-js).
```javascript
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
```