0
votes

RDS without access to the internet, the same VPC as Lambda. I can connect to RDS from EC2 in the same VPC. I tried to establish a socket connection from Lambda to RDS successfully:

import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print(s.connect(('xxx.cmebgbnbfkax.eu-west-1.rds.amazonaws.com', 5432)))

In logs I see None so connection was successful, but I get timeout on connection through psycopg2:

psycopg2.connect(
    host='xxx.cmebgbnbfkax.eu-west-1.rds.amazonaws.com',
    dbname=<my db name>,
    user=<my usernamr>,
    password=<my password>)

I set maximum timeout on Lambda - 60 seconds. Security group allow access to the port 5432. As I understand if I can establish socket connection to the database - it is mean that all preferences about networking is ok? So where can be a problem?

1
How does None mean the connection was successful? - Michael - sqlbot
@Michael-sqlbot because on incorrect connection will through ConnectionRefusedError - Vitaly Zdanevich

1 Answers

0
votes

My solution: I migrated to the DynamoDB - now I do not need compiled psycopg2 in deployment archive with statically linked libraries.