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 Respostas
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
ESPECIALISTA
respondido há 9 meses
profile picture
ESPECIALISTA
avaliado há 9 meses
profile pictureAWS
ESPECIALISTA
avaliado há 9 meses
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
ESPECIALISTA
Steve_M
respondido há 9 meses
0

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

Afshaar
respondido há 9 meses

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas