0
votes

I have created an AWS Lambda function in the default VPC which is running every 5 minutes. The Lambda function is making JDBC connection to fetch data from RDS.

I am getting following error:

com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. 

The RDS instance in a us-east region, The Lambda and EC2 are in a us-west region

I am able to access RDS in my EC2 ubuntu machine but not able to access RDS in the Lambda function. My security group is allowing access from anywhere to MySQL port 3306.

1

1 Answers

0
votes

When you mentioned you are able to access RDS MYSQL on its default port 3306, that means you should be able to connect to your RDS from your lambda function also. I also assume you are using any python module to coonect to RDS mysql in your lambda function. In that case; try having the VPC configuration at lambda is same as the RDS is in.

import pymssql
conn = pymssql.connect(server, user, password, "tempdb", port=3306)
cursor = conn.cursor()