Reputation: 789
Getting following error when i run the nodejs lambda code.
"errorType": "Runtime.HandlerNotFound", "errorMessage": "index.handler is undefined or not exported",
the folder structure is
audit_package
- nodejs
- node.js
The lambda handler name is "index.handler" runtime package is "nodejs12.x"
Dont pass any paramters while invoking lambda.
Here is the code
console.log('function starts');
const AWS = require('aws-sdk');
const docClient = new AWS.DynamoDB.DocumentClient({region: 'us-west-2'});
exports.handler = function(event, context, callback){
console.log('processing event: %j', event);
let scanningParameters = {
TableName: 'epro-audit-cert',
Limit: 10 //maximum result of 100 items
};
//In dynamoDB scan looks through your entire table and fetches all data
docClient.scan(scanningParameters, function(err,data){
if(err){
callback(err, null);
}else{
callback(null,data);
}
});
Upvotes: 1
Views: 6703
Reputation: 238975
You have to adjust your handler:
Handler – The method that the runtime runs when your function is invoked, such as index.handler. The first value is the name of the file or module. The second value is the name of the method.
Since you have your file in nodejs
folder, it should be:
nodejs/node.handler
Upvotes: 1