Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/djhworld/go-lambda-invoke
https://github.com/djhworld/go-lambda-invoke
aws aws-lambda go golang
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/djhworld/go-lambda-invoke
- Owner: djhworld
- License: mit
- Created: 2018-01-26T20:21:09.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-31T10:49:51.000Z (over 5 years ago)
- Last Synced: 2024-06-18T18:46:13.999Z (7 months ago)
- Topics: aws, aws-lambda, go, golang
- Language: Go
- Size: 8.79 KB
- Stars: 83
- Watchers: 4
- Forks: 14
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# go-lambda-invoke
Small package to allow you to invoke your Go AWS lambda locally.
This _might_ be useful for:
* You want to run an integration test, maybe in conjunction with [LocalStack](https://github.com/atlassian/localstack)?
* Unit testing is probably better in most cases
* You want to validate your CI has built a valid `linux` binary of your application before deployingI wrote a blog post about it here https://djhworld.github.io/post/2018/01/27/running-go-aws-lambda-functions-locally/
## Installing
```
go get -u github.com/djhworld/go-lambda-invoke/golambdainvoke
```## Example usage
Run the example lambda [toupperlambda.go](/toupperlambda.go) on port 8001
```
_LAMBDA_SERVER_PORT=8001 go run ./toupperlambda.go
```Then use this library in tests or wherever you need it, by calling
```
response, err := golambdainvoke.Run(Input{
Port: 8001,
Payload: "payload",
})
```Note that `Payload` can be any structure that can be encoded by the `encoding/json` package. Your lambda function will need to use this structure in its type signature.