lambci / docker-lambda

Docker images and test runners that replicate the live AWS Lambda environment
MIT License
5.83k stars 431 forks source link

Handle different functions #293

Open acgpiano opened 4 years ago

acgpiano commented 4 years ago

sam local start-api will cost a lot of time so I found this project, but how can I handle different functions. If I have two files with two different functions fun1.handler and fun2.handler, how can I run one server to handle two functions

krimple commented 3 years ago

I've been experimenting with docker-compose having different containers in stay-open mode for each Lambda, and I figured that I'd just pass the endpoint url and ARNs for each Lambda to the calling program in a configuration file that I'd vary by platform (local, dev, test, prod). Is that what other people are doing? This way each Lambda is its own thing, but you can also choose to have the functions in the same folder and share layers for testing purposes. It would be great to have support for multiple lambdas in one engine with different function names.

mhart commented 3 years ago

Yeah, multiple endpoints is the supported method. Not sure I'll ever add support for multiple functions per container – it would mess with a lot of the semantics and fidelity of trying to match how Lambda works in reality (which is a function per container)

mhart commented 3 years ago

You could use a reverse proxy that sits in front of the containers and does the routing for you – then you'd only need a single endpoint from your app code