Lambda Function:
const client = new Client({
user: 'postgres',
host: 'rds_host',
database: 'dbname',
password: 'db_password',
port: 5432
});
exports.handler = async (event, context, callback) => {
try {
await client.connect();
callback(null, "Connected Successfully");
} catch (e) {
callback(null, "Error");
}
};
With this code my lambda always get a timeout error, if I get rid of the cliente.connect() line, it works fine.
The interesting part is that if I add a client.query with INSERT the command does work and the row is created at the DB, so why I get a timeout when the client.connect() is added and the connection works?