Can I write one Lambda Function to Handle Multiple REST API Requests. I have my data in Dynamo DB
Flow: API Gateway-->Lambda Function-->Dynamo DB Example:
Request1:GET Method-Need to pull data from Table1
/device/{device_id}/start/{start_date}/end/{end_date}/events
Request2:GET Method-Need to pull data from Table2
/device/{device_id}/start/{start_date}/end/{end_date}/event_count
Request3:POST Method-Need to put data from Table3
/device/{device_id}/start/{start_date}/end/{end_date}/fault_events
What is the best solution should I write 3 different lambda functions to handle 3 different requests or can I handle all the 3 requests in one BIG Lambda Function.
> You can definitely achieve multiple lambda functions from one code base using the Lambda Bootstrapper and the custom runtime feature.
In order to allow the ParentFunction to call the ChildFunction, we need to provide the ParentFunction with specific rights to call another lambda function. This can be done by adding specific policies to a role and then assign that role to the lambda function.
The default concurrency limit per AWS Region is 1,000 invocations at any given time. The default burst concurrency quota per Region is between 500 and 3,000, which varies per Region. There is no maximum concurrency limit for Lambda functions.
Yes, you can have one Lambda function that handle more than one API. The question is why?
Doing this is considered (almost) an anti-pattern as you won't be able to scale independently the various scenario.
These are two slides from the link pasted above from Chris Munns talk at last re:invent and I strongly agree.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With