1
votes

Is it possible to set a custom request integration timeout in AWS API Gateway in serverless.yml configuration?

Although the question is quite straight forward I find a little of context always useful:

I need to notify the final user when the lambda function has timed out. Such situation could happen due to project requirements (lambda is communicating with third-party systems that may not be up). I came up with some other solutions, I believe setting the API-GW request timeout to the same time as lambda timeout is the best one, though.

1
Do you ask, how to set specific timeout for APIGW endpoint? Or do you ask how to notify user that you're unable to fulfill request, before actually timeout takes place? - Mariusz Nowak
@MariuszNowak I ask how to set a specific timeout for APIGW endpoint :) - kazbeel
Unfortunately there's no out of a box supported for that in Serverless Framework. Still please post a request, also PR is very welcome - Mariusz Nowak
@MariuszNowak Thanks for the answer :) - kazbeel
For now using AWS CLI is the best bet to manually update the integration timeout. This is what we used to solve our issue manually. aws apigatewayv2 update-integration --integration-id <integration-id> --api-id <api id> --timeout-in-millis <time in milliseconds> - Sujan

1 Answers

1
votes

Realised that with the recent update in serverless framework - function timeout is respected across the integration. All you have to do is pass timeout value in your function.

Here is an example:

functions: myfunction: handler: public/index.php timeout: 15 #This will be same for integration timeout in API Gateway. tags: project: myproject