我试图创建一个简单的lambda函数,但遇到了错误。
我的代码基本上是
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');
}
在helloworld.js文件中。我将其压缩并在创建lambda函数部分中将其作为zip文件上传,并且不断出现此错误:
{
"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)"
]
}
有人有主意吗?
文件名需要与Handler配置中的模块名匹配。在这种情况下,您的Handler应该设置为helloworld.handler
,helloworld
这是require()所需的文件,并且handler
是导出的函数。然后,它将使用相同的zip文件。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句