https://github.com/treasure-data/lambda-local-proxy
Local API proxy that calls an AWS Lambda function
https://github.com/treasure-data/lambda-local-proxy
Last synced: about 2 months ago
JSON representation
Local API proxy that calls an AWS Lambda function
- Host: GitHub
- URL: https://github.com/treasure-data/lambda-local-proxy
- Owner: treasure-data
- License: apache-2.0
- Created: 2020-11-12T18:22:22.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2023-07-11T20:54:23.000Z (almost 3 years ago)
- Last Synced: 2025-04-23T13:59:14.653Z (about 1 year ago)
- Language: Go
- Size: 31.3 KB
- Stars: 7
- Watchers: 63
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Awesome Lists containing this project
README
# Lambda Local Proxy
Lambda Local Proxy is a HTTP proxy that receives HTTP requests and invokes an AWS Lambda function. By combining with [lambci/docker-lambda](https://github.com/lambci/docker-lambda), you can test Lambda handler code locally or on CI without deploying.
This proxy can emulate following event formats at this moment:
* Application Load Balancer (ALB)
* Application Load Balancer (ALB) with multi-value headers enabled
## Usage
```
Usage of lambda-local-proxy:
-e string
Lambda API endpoint
-f string
Lambda function name (default "myfunction")
-l string
HTTP listen address (default any)
-m Enable multi-value headers. Effective only with -t alb
-p int
HTTP listen port (default 8080)
-t string
HTTP gateway type ("alb" for ALB) (default "alb")
Environment variables:
AWS_REGION, AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SESSION_TOKEN
```
Once it starts, access `http://localhost:8080` to invoke a lambda function.
Examples:
```bash
# Invoking local code through lambci/docker-lambda
$ docker run --rm \
-e DOCKER_LAMBDA_WATCH=1 -e DOCKER_LAMBDA_STAY_OPEN=1 -p 9001:9001 \
-v "$PWD":/var/task:ro,delegated \
lambci/lambda:python3.8 lambda_function.lambda_handler
$ lambda-local-proxy -e http://localhost:9001 -t alb
```
```bash
# Invoking a deployed Lambda function
$ export AWS_REGION=...
$ export AWS_ACCESS_KEY_ID=...
$ export AWS_SECRET_ACCESS_KEY=...
$ lambda-local-proxy -t alb
```
## Development
### Build
```
$ go build
```
### Release
See [GoReleaser](https://goreleaser.com/) documents.
Cheat sheet:
```
# Build packages in ./dist
goreleaser --snapshot --skip-publish --rm-dist
# Release
git push # make sure you pushed
git push --tags # code and tags.
env GITHUB_TOKEN=... goreleaser
```
## License
Apache License, Version 2.0.
Copyright (C) 2020 Treasure Data Inc.