Sign inSign up

justinmchase/lambda-hub

By justinmchase

•Updated almost 6 years ago

Invoke lambda functions with a simple REST api

Image
0

583

justinmchase/lambda-hub repository overview

⁠lambda-hub


This supports invoking lambda functions via a simple REST api for local testing.

⁠Example

Here is an example of how to trigger a lambda function from an S3 event

# docker-compose.yml
version: "3"
services:
  # Local S3 instance
  s3rver:
    image: justinmchase/s3rver
    ports:
      - "4569:4569"
    links:
      - "hub"
    environment:
      SUBSCRIBE: "ObjectCreated:Put(http://subscriber:2354/example/index.handler)"

  hub:
    image: justinmchase/lambda-hub
    ports:
      - "2354:2354"
    volumes:
      - ".:/var/tasks"
// index.js
exports.handler = function (event, context) {
  return new Promise((resolve, reject) => {
    console.log('Hello lambda!')
    console.log(event)
    resolve({ ok: true })
  })
}
# shell 1
$ docker-compose up
# ...
example_hub_1 | Hello lambda!
example_hub_1 | { Records: [ ... ] }
# shell 2
$ aws s3 mb example
$ aws s3 cp ./hello.txt s3://example/hello.txt --endpoint-url http://localhost:4569

or

$ curl http://localhost:2354/example/index.handler

Tag summary

Content type

Image

Digest

Size

352.6 MB

Last updated

almost 6 years ago

docker pull justinmchase/lambda-hub