= records[i]; var header = { "index":{ "_index": ES_INDEX, "_type": ES_TYPE, "_id": record.eventTime + "-" + record.requestID } }; var searchRecord = { "usertype" : record.userIdentity.type, "arn" : record.userIdentity.arn, "username" : record.userIdentity.userName, "eventtime" : record.eventTime, "eventsource" : record.eventSource, "eventname" : record.eventName, "awsregion" : record.awsRegion, "sourceipaddress" : record.sourceIPAddress, "eventid" : record.eventID, "logfilename" : logFileName }; searchRecords.push(header); searchRecords.push(searchRecord); }; Lambda Code s3.getObject({ Bucket : bucket, Key : key }, function(err,data) { if(err){ context.done('error','error getting file' + err); } else { var contentType = data.ContentType; var contentEncoding = data.ContentEncoding; if (contentType === "application/json" && contentEncoding === "gzip") { var logFileName = key.substr(key.lastIndexOf("/") + 1); var buf = data.Body; zlib.gunzip(buf, function(_, dezipped) { var json = JSON.parse(dezipped.toString('utf-8')); sendToES(context,region,logFileName,json); }); } } }); }; //bulk send to Elasticsearch function sendToES(context,region,logFileName,json){ var records = json.Records; var searchRecords = []; zip用 node moduleが必要