#Unable to Connect to Postgres RDS Database

5 messages · Page 1 of 1 (latest)

kind patio
#

Below is a summary of what i have tried (created by AI as it has worked through this with me):

AWS Configuration Details
SSM Parameter

Parameter exists in AWS Systems Manager Parameter Store
Parameter is stored with a hierarchical path structure
Parameter type: SecureString
Parameter contains a valid PostgreSQL connection string
VPC Configuration
The database is deployed within a VPC
A security group is configured for the database
Multiple subnets are configured across different availability zones
Troubleshooting Steps Taken
Updated the schema.sql.ts file to use the full path of the SSM parameter
Verified the SSM parameter exists and contains a valid connection string
Created a test connection function in the frontend component
Added detailed error handling and debugging information
Expected Behavior
The Lambda function should be able to retrieve the database connection string from SSM Parameter Store and successfully connect to the PostgreSQL database, allowing the frontend to create, read, update, and delete records.
Actual Behavior
The Lambda function fails to retrieve the connection string from SSM Parameter Store, resulting in the error "Unable to fetch the connection Uri from SSM for the provided paths" and preventing any database operations.
Technical Environment
AWS Amplify Gen 2
React frontend
PostgreSQL database in Amazon RDS
Database accessed through VPC
Connection string stored in SSM Parameter Store as a SecureString
Additional Information
The issue appears to be related to one or more of the following:
Lambda function IAM permissions for accessing the SSM parameter
VPC configuration and security group settings
Parameter encryption and access
Lambda function configuration
I've attempted to enable DEBUG_MODE on the Lambda function to get more detailed error information, but the same error persists.

#

Cloudwatch Error for SQLFunction:

    Link 
    INFO    Unable to fetch the connection Uri from SSM for the provided paths.
    
ERROR Invoke Error {"errorType":"Error","errorMessage":"Unable to connect to the database. Check the logs for more details.","stack":["Error: Unable to connect to the database. Check the logs for more details."," at /var/task/handler.js:165:15"," at Generator.throw (<anonymous>)"," at rejected (/var/task/handler.js:6:65)"," at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"]}
ERROR    Invoke Error     
{
    "errorType": "Error",
    "errorMessage": "Unable to connect to the database. Check the logs for more details.",
    "stack": [
        "Error: Unable to connect to the database. Check the logs for more details.",
        "    at /var/task/handler.js:165:15",
        "    at Generator.throw (<anonymous>)",
        "    at rejected (/var/task/handler.js:6:65)",
        "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
    ]
}```

I can confirm the SQLFunction is in the same VPC as the DB and has access to the parameter in Systems Manager when checking the permissions tab
kind patio
#

Is anyone able to help me with this issue? <@&705906736388898918>

outer juniper