I try to connect to a MySQL RDS database and getting a timeout error:
"Can't connect to MySQL server on
'XXXXXXX.XXXXXXX.us-east-1.rds.amazonaws.com' (timed out)")
The AWS Lambda can connect to AWS RDS Secrets, but looks like no with AWS RDS Proxy. The lambda in a VPC. Here is the code i using on Python:
def connect_mysql(secret, pipeline):
import pymysql
import pymysql.cursors
dbname = pipeline["aws"]["rds"]["dbname"]
user = secret["username"]
host = secret["host"]
password = secret["password"]
try:
# Connect to the database
connection = pymysql.connect(host=host,
user=user,
password=password,
database=dbname,
cursorclass=pymysql.cursors.DictCursor)
logger.info(f"Connected to: {dbname}")
except:
traceback.print_exc()
logger.warning(f"Error connecting AWS RDS")
return connection