@aiir/lambda-proxy

Simulates AWS API Gateway with Lambda proxy integration locally for development.

Usage no npm install needed!

<script type="module">
  import aiirLambdaProxy from 'https://cdn.skypack.dev/@aiir/lambda-proxy';
</script>

README

API Gateway Lambda Proxy

Simulates AWS API Gateway with Lambda proxy integration locally for development.

All paths will proxied to the Lambda function as if the API Gateway stage is configured with a standard root and Proxy Resource (e.g. {proxy+}) both configured to use the same Lambda function.

The Lambda function is invoked via the lambci/lambda Docker container, to give a runtime environment as close as possible to the real thing.

Requirements

As well as Node.js 8.10 or later, Docker must also be installed and running on the same machine to run the Lambda emulation container.

Installation

Install the package globally so you can use it easily within your actual Lambda project.

$ npm install -g @aiir\lambda-proxy

This will add a lambda-proxy executable to PATH.

Usage

By default, the script will attempt to start an HTTP server on port 3000 and for any incoming request execute a Node.js 8.10-based Lambda function called handler from index.js from the current directory:

lambda-proxy

You can modify this behaviour through the following environment variables:

TASK_DIR
Sets the path to the directory containing the Lambda script. Defaults to the current directory.
RUNTIME
Allows you to set which Lambda runtime you want. This sets which Docker container tag to use, refer to the documentation for a full list of available tags. Defaults to nodejs8.10.
HANDLER
Changes the file and handler function, e.g. index.myHandler uses the file index.js and the function myHandler. Defaults to index.handler.
STAGE
Sets the API Gateway stage name included in the event object sent to the Lambda function. Defaults to development.
NETWORK
Allows you to optionally override the default network of the Lambda function execution Docker container, for example to link it with a container acting as a VPN client.

Authors

License

MIT