Q:

How to set AWS lambda timeout using request parameters?

I want to build an API where end user can set timeout. Not to be confused with the usual timeout setting in serverless.yml file.
def main(event, context):
    timeout=event["timeout"] # use this

A:

One solution would be to globally configure your lambda functions to time out at the maximum (15 minutes, currently).
Then your handler would need to fork your lambda process, and have the parent process kill the child process (which is where your actual application code will be) after the user-specified amount of time.

