I am working on an application where i want to connect to postgresql database from AWS lambda.I have setup the database with Publicly Accessible property set as true.Inbound and outbound policies are
I am able to access the database through pgAdmin client but not able to do so through aws lambda.I have also associated AWSRDSFULLACCESS policy to lambda role and added vpc and subnet and security groups information to the advanced settings section.
I am getting following timeout error errorMessage": "2017-04-15T11:26:05.163Z 4ac2cf66-21ce-11e7-a6da-a7d26945c336 Task timed out after 9.00 seconds"
Node.js code I am using to connect to RDS is
var pg = require("pg");
exports.handler = (event, context, callback) => {
// TODO implement
const connectionStr = "pg://username:password@hostendpoint:5432/database name";
var client = new pg.Client(connectionStr);
client.connect(function(err){
if(err) {
callback(err)
}
callback(null, 'Connection established');
});
};
How can I access the RDS from AWS Lambda?