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 Answers
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
EXPERT
answered 8 months ago
profile picture
EXPERT
reviewed 8 months ago
profile pictureAWS
EXPERT
reviewed 8 months ago
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
EXPERT
Steve_M
answered 8 months ago
0

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

Afshaar
answered 8 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions