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 个月前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则