Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lambda-local

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lambda-local

Commandline tool to run Lambda functions on your local machine.

  • 2.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
168K
decreased by-10.65%
Maintainers
2
Weekly downloads
 
Created

What is lambda-local?

The lambda-local npm package allows you to run and test AWS Lambda functions locally. This can be useful for development and debugging purposes, as it enables you to simulate the AWS Lambda environment on your local machine.

What are lambda-local's main functionalities?

Run Lambda Function Locally

This feature allows you to execute a Lambda function locally by specifying the event, the path to the Lambda function, AWS credentials, and a timeout. The code sample demonstrates how to set up and run a Lambda function locally using lambda-local.

const lambdaLocal = require('lambda-local');
const path = require('path');

lambdaLocal.execute({
    event: require('./event.json'),
    lambdaPath: path.join(__dirname, 'index.js'),
    profilePath: '~/.aws/credentials',
    profileName: 'default',
    timeoutMs: 3000
}).then(function(done) {
    console.log(done);
}).catch(function(err) {
    console.log(err);
});

Simulate AWS Context

This feature allows you to simulate the AWS context object that is passed to Lambda functions. The code sample shows how to define a custom context and use it when executing a Lambda function locally.

const lambdaLocal = require('lambda-local');
const path = require('path');

const context = {
    functionName: 'myLambdaFunction',
    awsRequestId: '1234567890',
    logGroupName: '/aws/lambda/myLambdaFunction',
    logStreamName: '2021/01/01/[$LATEST]abcdef1234567890'
};

lambdaLocal.execute({
    event: require('./event.json'),
    lambdaPath: path.join(__dirname, 'index.js'),
    context: context,
    timeoutMs: 3000
}).then(function(done) {
    console.log(done);
}).catch(function(err) {
    console.log(err);
});

Custom Environment Variables

This feature allows you to set custom environment variables for your Lambda function. The code sample demonstrates how to set an environment variable and use it when running a Lambda function locally.

const lambdaLocal = require('lambda-local');
const path = require('path');

process.env.MY_ENV_VAR = 'myValue';

lambdaLocal.execute({
    event: require('./event.json'),
    lambdaPath: path.join(__dirname, 'index.js'),
    timeoutMs: 3000
}).then(function(done) {
    console.log(done);
}).catch(function(err) {
    console.log(err);
});

Other packages similar to lambda-local

Keywords

FAQs

Package last updated on 08 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc