Search code examples
amazon-web-serviceslambdaaws-lambdaaws-step-functions

AWS lambda times out when called by Step Function, or scheduled event. How to avoid?


I have a lambda function that calls an external API (which takes more than 30 seconds) and returns data. Based on the step function docs, I thought that I could avoid the lambda timeout limit of 30 seconds by calling the lambda function through a scheduled cloudwatch event. That doesn't seem to be the case. How can I call a long running lambda function? I've tried:

  1. calling the lambda function by invoking the CLI on my machine aws lambda invoke... TIMES OUT
  2. calling the step function (which calls lambda) by invoking the CLI on my machine aws stepfunctions start-execution... TIMES OUT
  3. running the function directly from my computer (not using lambda). Takes approx 45 seconds for api to respond. WORKS

Solution

  • As per the AWS docs here the function timeout limit on a Lambda functions is 900 seconds / 15 minutes.

    To resolve your issue, extend the function timeout limit on your Lambda function to the required duration.