- Newest
- Most votes
- Most comments
please check the connectionstring format it seems wrong
JDBC connection string format (Java applications):
jdbc:postgresql://<RDS_ENDPOINT>:<PORT>/<DB_NAME>?user=<USERNAME>&password=<PASSWORD>
Replace <RDS_ENDPOINT>, <PORT>, <DB_NAME>, <USERNAME>, and <PASSWORD> with your specific values.
Example:
jdbc:postgresql://xxx.us-west-2.rds.amazonaws.com:5432/xxx?user=xxx&password=xxx
Please make sure that the security group you have selected while creating the lambda function (SecurityGroupIds) has an inbound rule allowing connection from your database on port 5432.
Yes, I created an inbound rule but I don't know what IP if choose "Custom" source (if select "Anywhere-IPv4" and 0.0.0.0/0, then it works). Could you tell me how to config inbound rule so only lambda can connect to RDS?
A good practice is to select the respective 'security group id' instead of IP addresses. With 'Custom' as source, you should be able to select security groups. In the Inbound rules of security groups of lambda and RDS, make sure that you only select the security groups of each other to allow access only between them. Hope this helps
Thank you for your helps. I added subnet's IPs to security group, it works now.
Relevant content
- asked 2 years ago
- Accepted Answerasked 8 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 months ago
Thanks for your answer. My connection string format with "xxx" is just an example and it follows the format jdbc:postgresql://<RDS_ENDPOINT>:<PORT>/<DB_NAME>?user=<USERNAME>&password=<PASSWORD> The concern is that this works on my AWS Dev account but when I work on Prod account, it cannot connect to my prod database (I am able to connect to my prod DB with the credential that I used in JDBC connection string). Do you other suggestions on this?