Skip to content

Instantly share code, notes, and snippets.

View maxrabin's full-sized avatar

Max Rabin maxrabin

View GitHub Profile
@maxrabin
maxrabin / CountLinesAndLetters.js
Created March 13, 2016 12:09
Example Lambda Function to process lines of text files when uploaded to S3
'use strict';
var AWS = require('aws-sdk');
var S3 = new AWS.S3();
var readline = require('readline');
exports.handler = function (event, context) {
//Get S3 file bucket and name
//Make sure to loop through event.Records, don't assume there is only 1 in production!!!
var bucket = event.Records[0].s3.bucket.name;
var key = event.Records[0].s3.object.key;