0 votes
1 view
in AWS by (18.2k 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 (42.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

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...