I had a similar problem, which I solved with the following steps.
I created a new RDS instance in the management console. At this time, I specified that a new VPC, subnet group, and security group be created as well.
In this case, a rule was created with the source IP "22.214.171.124/32" as an inbound rule for the security group. In this state, I could still connect from the local PC, but not from Lambda. When I changed the source IP to 0.0.0.0.0/0, I was able to connect from Lambda.
Issues connecting to Postgres RDS instance from within a VPCasked 3 years ago
From docker container need to connect RDS - Using Session Managerasked a month ago
How can I connect Google Data Studio to an Private AWS RDS Postgres instance?asked 3 months ago
Why can't I find my RDS database from my lambda function?
AWS Lambda not able to connect to public RDS instanceasked 5 months ago
How to access a public RDS instance from lambda without compromising on the security of RDS by putting an inbound rule for RDS Sg with source as 0.0.0.0/0 ?Accepted Answerasked 4 months ago
Handler error when connecting lambda function to RDS database
How do I link my Amazon Connect instance to a Lambda function outside the contact flow with automationasked 3 months ago
Can't connect to an RDS Instance from Lambda (different account tough)asked 2 years ago
Connect to MemoryDB from LambdaAccepted Answerasked 3 months ago