I am trying to create a signup page using node.js in DynamoDB Lambda. Any useful link and suggestions would be appreciated. Following is my code:
var doc= require('dynamodb-doc');
var dynamo = new doc.DynamoDB();
exports.handler = function(event, context) {
var email = event.email;
var params = {
"TableName" : "SignupsTable",
"Item" : {
"type": "email",
"email": email,
"date": new Date().toISOString()
}
};
dynamo.putItem(params, function(err, data){
console.log(err);
console.log('Stored email' + email);
context.succeed('Stored email: '+email);
});
};
And the execution result is as follow:
Response:
{
"errorType": "Runtime.ImportModuleError",
"errorMessage": "Error: Cannot find module 'dynamodb-doc'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js",
"trace": [
"Runtime.ImportModuleError: Error: Cannot find module 'dynamodb-doc'",
"Require stack:",
"- /var/task/index.js",
"- /var/runtime/UserFunction.js",
"- /var/runtime/index.js",
" at _loadUserApp (/var/runtime/UserFunction.js:100:13)",
" at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
" at Object.<anonymous> (/var/runtime/index.js:43:30)",
" at Module._compile (internal/modules/cjs/loader.js:1133:30)",
" at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)",
" at Module.load (internal/modules/cjs/loader.js:977:32)",
" at Function.Module._load (internal/modules/cjs/loader.js:877:14)",
" at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)",
" at internal/main/run_main_module.js:18:47"
]
}
Request ID:
"66c61f6c-de39-4e27-8fa0-89dca597b15b"
An unknown application error occurred
Runtime.ImportModuleError