My AWS Lambda function times out when it ties to connect to an RDS instance in another VPC. The VPCs are peered.
Things I have checked:
5432
) to RDS security groupWhat else can I check / leverage to fix this connectivity issue?
Update
Update
I tried the following:
telnet
to RDS:telnet rds.xxxxxxxxxx.eu-west-2.rds.amazonaws.com 5432
Trying 10.11.65.225...
Connected to rds.xxxxxxxxxx.eu-west-2.rds.amazonaws.com.
Escape character is '^]'.
^CConnection closed by foreign host.
So the EC2 can connect. Therefore the issue must be with the lambda.
What can I try next?
The issue in my case (maybe yours too?) was that the query was timing out, not the connection attempt. You can test this by changing the query to SELECT 1 AS x
or similar. The solution is to optimize the query so that it can run in reasonable time.
The trick of launching an EC2 with similar settings to the Lambda and connecting via SSH is a good one.