When I try this code in local its works fine but not in an AWS Lambda function.
var Redshift = require('node-redshift');
var client = {
user: 'root',
database: 'yourdatabasename',
password: 'yourpassword',
port: 5439,
host: 'localhost',
};
var redshiftClient = new Redshift(client, {rawConnection:true});
exports.handler = async (event) => {
let response = [];
redshiftClient.connect(function(err){
console.log('After Connection');
if(err) throw err;
else{
redshiftClient.query('SELECT * FROM world.country', {raw: true}, function(err, data){
if(err) throw err;
else{
response = data;
console.log(data);
redshiftClient.close();
}
});
}
});
return response;
};
Could anyone tell me what's the matter with my coding?
Thank you very much!