Owen Burns
Owen Burns

Reputation: 140

AWS Lambda Python Boto3 client.invoke() times out no matter what parameters are entered

I am attempting to call one lambda function from another, and the code I am using in the calling function is:

client=boto3.client('lambda')
services={'Image_Processor':'arn'}
response=client.invoke(FunctionName=services[event['service']], InvocationType='DryRun', Payload=json.dumps(event))

There is no error message given, and I have tried setting the timeout duration as long as 10 minutes, but I still cannot get any result except:

{
  "errorMessage": "2021-08-12T17:13:18.946Z de2feefa-9923-40bd-a555-bf5de54712ee Task timed out after 20.02 seconds"
}

Any help would be very greatly appreciated.

Upvotes: 0

Views: 1323

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 269091

It appears that you are saying that Lambda function A is timing out when invoking Lambda function B.

A common scenario is that the timeout is caused by Lambda function A not having access to the Internet. The AWS API endpoint is on the Internet and Lambda function A requires Internet access to invoke Lambda function B.

To have Internet access, the Lambda function should either:

  • NOT be connected to a VPC (which then automatically provides Internet access), or
  • Be connected to a private subnet, and the VPC should have an Internet Gateway in a public subnet to grant access to the Internet, or
  • Configure interface VPC endpoints for Lambda, which creates a direct connection between a VPC and the AWS Lambda API endpoint

Upvotes: 2

Related Questions