I have a Lambda function triggered by a put event in an S3 bucket. When a file is added to the bucket, the lambda is correctly triggered, but it performs s3.getObject(params, (err, data) => {}) nothing happens.
The role of the Lambda function has the S3FullAccess policy attached.
I've tested the lambda locally (using sam) and everything works perfectly, but when the lambda is deployed nothing happens, no idea how to debug it neither.
const aws = require('aws-sdk');
const s3 = new aws.S3();
const bucket = event.Records[0].s3.bucket.name;
const key = event.Records[0].s3.object.key;
s3.getObject({Bucket: bucket, Key: key}, function(err, data) {
if (err) {
console.error(err);
}
console.log(data);
});
The scope of my lambda is:
- Read a CSV file from a private S3 bucket
- Load the content of the CSV files in a Database in a VPC
In order to let the lambda access the DB I've configured the lambda on the same VPC as the database.
Any idea?