"Task timed out after 30 seconds" connecting to Aurora Serverless from Django Lambda Function
Asked Answered
T

0

6

I want to connect to my Aurora Serverless mysql database inside of my django Lambda function. Currently, I have:

  • a Lambda function inside of the default VPC
    • Uses the default security group
    • Uses two public subnets I created
    • Allows inbound requests from TCP ports 1024 - 65535
    • Allows outbound requests to Aurora/Mysql on Aurora security group
  • an Aurora cluster inside of the default VPC
    • Uses the same (default) VPC as the Lambda
    • Uses two private subnets I created
    • Allows inbound requests on port 3306 from Lambda security group
  • an internet gateway for the default VPC
  • a NAT gateway which pipes communications to the internet gateway
  • a public routing table with the target ID of the internet gateway
  • a private routing table with the target ID of the NAT gateway

When I try to deploy my Lambda function to API gateway, the request times out:

START RequestId: [request id] Version: $LATEST
Instancing..
END RequestId: [request id]
REPORT RequestId: [request id]  Duration: 30030.15 ms   Billed Duration: 30000 ms   Memory Size: 512 MB Max Memory Used: 49 MB  
[time] [request id] Task timed out after 30.03 seconds

When I remove the Lambda function from the VPC (setting the VPC to none in the Lambda function's settings), it deploys to API gateway without any problems. This has led me to believe that my problem is with the VPC as opposed to with my database.

I used this question to try and rearrange the VPC to get it working but it has not worked.

Any help with getting the API to run and connect to the Aurora serverless cluster or alternative ways to use a database with django and Lambda functions would be great. Thanks!

Taken answered 27/3, 2020 at 19:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.