Can't access to data in S3 with Lambda : I´m using Javascript for a few months and my code runs well in local but I have always the same problem in a lambda function.

I cant show any data from s3.getObject.

This is an simple code that doesnt run on lambda function.



    var AWS = require('aws-sdk');
    var s3 = new AWS.S3();

    exports.myHandler = function(event, context, callback) {
        // Retrieve the object
        s3.getObject({
            Bucket: 'XXXXXX',
            Key: 'YYYYY'
        }, function(err, data) {
            if (err) {
                console.log(err);
            } else {
                console.log("data");
            }
        });
    };

