Reputation: 41939
I'm using the node-postgres client to my AWS Redshift database.
Locally, I'm able to run the following code in node
, getting print statements for ">> connected" and ">>> successful query. jsonResult: ".
However, when I run this code in Amazon Lambda, I don't see any log statements besides "trying to connect...".
console.log("trying to connect...");
var r = pg.connect(conString, function(err, client) {
if(err) {
return console.log('>> could not connect to redshift', err);
}
console.log(">> connected");
client.query('SELECT * FROM my_table', function(err, result) {
if(err) {
return console.log('error running query', err);
}
var jsonResult = JSON.stringify( result );
console.log(">>> successful query. jsonResult: " + jsonResult);
client.end();
return jsonResult;
});
});
I'm confused as to how no print statement, besides ">> trying to connect...," could show up in this code.
Upvotes: 5
Views: 10869
Reputation: 1454
Is it possible that you didn't attach the Lambda to the VPC? If this is the case, I suggest attaching it to two private subnets, and ensure that there is a NAT Gateway available for those subnets. You an find more information in this tutorial: https://github.com/awslabs/aws-lambda-redshift-loader
Upvotes: 0
Reputation: 132942
There are two things you should check
context.done()
so it's hard to know if you're handling this correctly. Are you calling context.done()
somewhere else?Upvotes: 3