lambdaでS3上にあるELBのログを読み取る方法

解析など細かなことを行いたい場合にはこういったライブラリなどもあるようです

https://www.npmjs.com/package/elb-log-analyzer

https://www.npmjs.com/package/elb-log-parser

CloudWatch Logsで簡単にログを見られるようにしておきたい場合などは以下のようにしてストリーミングすると良いようです。

exports.handler = function (event, context) {
    console.log('Received event: ', JSON.stringify(event, null, 2));

    /* == Streams ==
     * To avoid loading an entire (typically large) log file into memory,
     * this is implemented as a pipeline of filters, streaming log data
     */
    var lineStream = new LineStream();
    // A stream of log records, from parsing each log line
    var recordStream = new stream.Transform({objectMode: true});
    recordStream._transform = function (line, encoding, done) {
        var logRecord = parse(line.toString());
        var serializedRecord = JSON.stringify(logRecord);
        this.push(serializedRecord);
        totLogLines ++;
        done();
    }

    event.Records.forEach(function (record) {
        var bucket = record.s3.bucket.name;
        var objKey = decodeURIComponent(record.s3.object.key.replace(/\+/g, ' '));
        myFunction(bucket, objKey, context, lineStream, recordStream);
    });
};

https://github.com/awslabs/amazon-elasticsearch-lambda-samples/blob/master/src/s3_lambda_es.js

参考

http://qiita.com/dtlabo/items/e3e61b93f05cf7aac0db