Connecting a private RDS instance with a Lambda function

0

I'm trying to establish a connection between an AWS Lambda function and a private Amazon RDS PostgreSQL instance that are both situated within the same Virtual Private Cloud (VPC). I've taken the following steps:

  1. Placed the Lambda function and the RDS instance in the same VPC.
  2. Created a security group (Lambda-SG) for the Lambda function.
  3. In the inbound rules of the RDS security group (RDS-SG), I've allowed access from Lambda-SG.
  4. Attached the AWSLambdaVPCAccessExecutionRole to the Lambda function.

I'm encountering below issues. Could anyone guide me through the necessary configuration steps to successfully connect the Lambda function to the private RDS PostgreSQL instance?

"errorMessage": "FATAL: no pg_hba.conf entry for host "XX.X.X.XX", user "postgres", database "XXXXX", no encryption\n", "errorType": "OperationalError",

3 個答案
2

It looks like you're seeing the issue described in the documentation - have you tried the remediation steps there?

The error message you're getting tells me that the Lambda function is connecting to the database correctly at a networking level; but the database is denying access based on its configuration.

profile pictureAWS
專家
已回答 9 個月前
profile picture
專家
已審閱 9 個月前
profile pictureAWS
專家
已審閱 9 個月前
1

The no encryption part of the error message is worth looking into, is PostgreSQL configured to force SSL for connections? https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/PostgreSQL.Concepts.General.SSL.html

If it is then the lambda code will need to enable SSL too.

profile picture
專家
Steve_M
已回答 9 個月前
0

Your IAM permissions issue kindly allow API Access, RDS Access.

Afshaar
已回答 9 個月前

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

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

回答問題指南