raccoon4me
Hi, I'm starting with lambda function and I want to stream cloudtrail logs (stored in S3 bucket) to Elastic Search (same aws account). So i found you project and i did as follow: 1 - Clone you git repository 2 - Modify the example/index.js with this: ``` var shipper = require('lambda-stash'); var config = { elasticsearch: { host: 'https://my-elasticsearch-endpoint....es.amazon.com', region: 'us-east-1', useAWS: true }, mappings: [ { bucket: 'my-bucket-name-that-contain-cloudtrail-logs', processors: [ 'decompressGzip', 'parseJson', 'formatCloudtrail', 'shipElasticsearch' ], elasticsearch: { index: 'logs', type: 'cloudtrail' }, dateField: 'date' } ] }; shipper.handler(config, event, context, callback); ``` 3 - Create a zip file name package.zip (include clone of your repo with custom example/index.js file as shown above ``` ├── index.js ├── package.json ├── test ├── handlers ├── ... ├── example │ ├── index.js │ ├── package.json ``` 4 - Create a lambda blank function, add S3 trigger with event type (Object Created all) 5 - Chose node4.3 and upload my zip file create earlier 6 - Left the rest of options by default and click create 7 - Create a role to let lambda access to S3, cloudwatch and elasticcache and attach this role to my freshly create lambda function 8 - My lambda function is created but i'm unsure what i'm supposed to do next ? I don't see new indices being created on my ES cluster, i probably have missed ton of things like for example the handler which i let by default to index.handler, any chance you could give me a little hint on it please? EDIT: on my cloudwatch logs,**/aws/lambda/myfirstTest** it give the following result: ``` Unable to import module 'index': Error at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (/var/task/index.js:1:71) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17) ``` EDIT 3: 1 - I cloned you repo 2 - navigate to example and change the index.js as follow: ``` var shipper = require('lambda-stash'); var config = { elasticsearch: { host: 'https://my-elasticsearch-endpoint....es.amazon.com', region: 'us-east-1', useAWS: true }, mappings: [ { bucket: 'my-bucket-name-that-contain-cloudtrail-logs', processors: [ 'decompressGzip', 'parseJson', 'formatCloudtrail', 'shipElasticsearch' ], elasticsearch: { index: 'logs', type: 'cloudtrail' }, dateField: 'date' } ] }; shipper.handler(config, event, context, callback); ``` 3 - run npm install (it downloaded all the dependencies) 4 -create a zip file and uploaded to to lambda The error is now: ``` { "errorMessage": "event is not defined", "errorType": "ReferenceError", "stackTrace": [ "Object.Module._extensions..js (module.js:416:10)", "Module.load (module.js:343:32)", "Function.Module._load (module.js:300:12)", "Module.require (module.js:353:17)", "require (internal/module.js:12:17)" ] } ``` Still no luck :( Thanks a ton in advance