aws-lambda-runtime-proxy

Crates.ioaws-lambda-runtime-proxy
lib.rsaws-lambda-runtime-proxy
version0.2.1
sourcesrc
created_at2024-04-01 12:22:56.834281
updated_at2024-04-09 11:08:26.1092
descriptionA helper lib to customize the communication between the lambda handler process and the lambda runtime api.
homepage
repositoryhttps://github.com/DiscreteTom/aws-lambda-runtime-proxy
max_upload_size
id1192458
size29,437
DiscreteTom (DiscreteTom)

documentation

README

AWS Lambda Runtime Proxy

Crates.io Version license

overview

A helper lib to customize the communication between the lambda handler process and the lambda runtime api.

Usage

Installation

Add the following to the dependencies in your Cargo.toml:

aws-lambda-runtime-proxy = "0.2"

or run:

cargo add aws-lambda-runtime-proxy

Examples

A real world case: AWS Lambda Log Proxy.

Documentation

FAQ

What's the Purpose of this Project?

  • Override reserved environment variables like AWS_LAMBDA_RUNTIME_API.
  • Capture or modify the output of the handler function, including the stdout, stderr, or the return value.
  • Add additional command line arguments to the handler process.

How Does This Work?

proxy

This library will do the following:

  • Start an HTTP server to act as the fake AWS Lambda runtime API server, accepting requests from the handler process.
  • Spawn the handler process as a child process, with the environment variables modified to point to the fake AWS Lambda runtime API server.
  • (Optional) Forward requests from the handler process to the real AWS Lambda runtime API server.

Based on this setup, you can write your own logic to process the requests and responses between the handler process and the AWS Lambda runtime API.

Performance

See benchmark. TLDR: the proxy will introduce less than 2ms latency, which is acceptable for most use cases.

CHANGELOG

Commit count: 58

cargo fmt