Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in AWS by (19.1k points)

I am trying to create a simple lambda function, and I'm running into an error.

My code is basically

console.log('Loading function');

exports.handler = function(event, context) {

    console.log('value1 =', event.key1);

    console.log('value2 =', event.key2);

    console.log('value3 =', event.key3);

    context.succeed(event.key1);  // Echo back the first key value

    // context.fail('Something went wrong');

}

in a helloworld.js file. I zip that up and upload it as a zip file in the creating a lambda function section, and I keep getting this error:

{

  "errorMessage": "Cannot find module 'index'",

  "errorType": "Error",

  "stackTrace": [

    "Function.Module._resolveFilename (module.js:338:15)",

    "Function.Module._load (module.js:280:25)",

    "Module.require (module.js:364:17)",

    "require (module.js:380:17)"

  ]

}

Does anyone have any idea?

1 Answer

0 votes
by (44.4k points)

When you create a Lambda function, you need to provide the Handler name for it. Your Handler name would be UploadedFileName.HandlerMethodName

So, in your case. helloworld.js is the filename and considering your Method name is handler_function, it would look like this:

helloworld.handlerfunction

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

Browse Categories

...