Lambda connection to RDS timeout

0

I am trying to establish a connection from my lambda function to RDS instance (Aurora MySQL) using TypeORM

Scenario 1:

When trying to connect to RDS instance using mysql2 driver and using creds (host, database name, username, password), the **connection **timeout

Scenario 2:

When trying to connect to RDS instance using typeorm-aurora-data-api-driver driver and using creds (resourceARN, secretARN), the **lambda **timeout

Note :

  • I successfully established a connection to the DB using Mysql Workbench

  • Lambda Timeout is set to 30s

Scenario 1:

Scenario 1

Scenario 1

Scenario 2:

Scenario 2

Scenario 2

1 個回答
2

Hello.

Is Lambda connected to the same VPC as RDS?
If you are not connected, please connect to VPC by following the steps in the document below.
https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html#vpc-configuring

Make sure that you allow the Lambda function's security group connection in the RDS security group inbound rule.
https://repost.aws/knowledge-center/connect-lambda-to-an-rds-instance

profile picture
專家
已回答 1 個月前
profile picture
專家
已審閱 1 個月前
profile picture
專家
已審閱 1 個月前
profile pictureAWS
專家
已審閱 1 個月前
  • Lambda's VPC is connected to the RDS VPC via VPC peering I checked the security group, all traffic is allowed (for testing purposes)

  • Have you checked the route table of the subnet that Lambda is linked to? A route to the VPC peering must be configured in the route table. This requires that the route to the VPC peering be set in the RDS subnet route table as well. In other words, the settings must be configured to allow communication between VPCs in both directions.

  • I checked the VPC peering Connections in the "Edit DNS Setting" and it turned out that I wasn't enabling the "resolve DNS of requester VPC hosts to private IP." checkbox in both VPCs (Accepter VPC and Requester VPC) and this solved the issue , but am wondering why this checkbox solved the issue while in the inbound rules of the VPC I was allowing all Mysql aurora traffic Ipv4 connections along with the CIDR entries connections from the Peer VPC ?

  • The VPC needs to resolve public IPv4 DNS hostnames to private IPv4 addresses when queried from instances in the peer VPC. Here is more detail. https://repost.aws/knowledge-center/vpc-peering-troubleshoot-dns-resolution

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南