I am working in AWS Lambda with a Postgres RDS, and I am trying to move my database management code into a Lambda Layer that can be shared across functions. The code works perfectly fine in the function, but when I move it to the layer it dies with the error:
Unhandled Promise Rejection
{
"errorType":"Runtime.UnhandledPromiseRejection",
"errorMessage":"Error: self-signed certificate in certificate chain",
...
}
The gist of my Postgres client code is as follows:
const pg = require('pg')
# db_info is pulled from Secrets Manager
let client = new pg.Client({
host: db_info.host,
user: db_info.username,
database: db_info.dbName,
password: db_info.password,
port: db_info.port,
ssl: true
});
client.connect();
I am a newbie to AWS Lambda, so I'm somewhat flying blind. Any suggestions are greatly appreciated.