1

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);
        }
    });
1
  • change your folder structure and file name as below and try. audit_package - index.js Commented Mar 29, 2021 at 6:23

2 Answers 2

1

This is working now. Moved index.js to root folder

Sign up to request clarification or add additional context in comments.

1 Comment

where? in aws console?
1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.