0
我在獲取Node.js Lambda腳本時遇到了一些麻煩。我已經縮小到腳本需要兩個Nodes.js模塊(請求和mongojs)的事實。AWS Lambda w/Node.js依賴關係
var request = require('request'),
mongojs = require('mongojs'),
db = mongojs('CONNECTION_STRING_HERE', ['events']);
exports.handler = function(event, context) {
var data = event.Records[0].kinesis.data,
body = new Buffer(data, 'base64').toString('utf-8');
db.events.insert({
event_id: '00030050-0000-1000-8000-30f9ed09e058',
type: {
primary: 'CameraDiscovery',
secondary: 'Probe'
},
source: {
source_id: '40:16:7e:68:8b:5c',
type: 'ENVR'
},
payload: body,
created_at: new Date(),
last_modified: new Date()
}, function(err, doc) {
if (err) return context.fail(err);
context.succeed('Processed Event');
});
};
如何確保編譯依賴項以便代碼可以執行?