jkehler / awslambda-psycopg2

1.12k stars 363 forks source link

Read timed out error after 5 mins, and drop the connection #41

Closed linusliu closed 5 years ago

linusliu commented 5 years ago

lambda function will drop the connection after 5 mins, with error message: "errorType": "ReadTimeout", "errorMessage": "HTTPSConnectionPool(host='lambda.us-east-1.amazonaws.com ', port=443): Read timed out. (read timeout=60)"

phouse512 commented 5 years ago

This is likely because you have some VPC misconfigurations inside your lambda function. Does your Lambda function have internet access or is it in a private vpc?

linusliu commented 5 years ago

Thank you for your quick response. 1) lambda function VPC setting is 'NO VPC'; 2)The security group setting for the RDS postgres instance is: Inbound/Outbound Type| Protocol|Port Range|Source All traffic | All | All | 0.0.0.0/0

jkehler commented 5 years ago

Lambda functions don’t have internet access by default. You should put your database into a VPC and then grant the lambda function access to that VPC

linusliu commented 5 years ago

In the RDS instance, we already set VPC: vpc-791ae516 , and In Lambda function , the role has AmazonRDSFullAccess permission, any else permission I should grant?

phouse512 commented 5 years ago

If your RDS instance is in a VPC, your Lambda function needs to be in the same VPC so that it can access it. The role is more about permissions, not about networking configuration. In your Lambda configuration, set the same vpc + subnets.