I am trying to process uploaded file in S3. Since getObject is asyncronous main function ends before processing is done, and AWS kills lambda in 3-4 seconds
I think your lambda function should end with a context.done() call. For instance, try adding it this way:
s3.getObject(params, function(err, data) {
if (err) {
...
context.done("Error: " + err.stack);
} else {
processFile(data.Body.toString(), 0);
console.log("ok");
context.done(null, "success");
}
});