我正在尝试创建一个简单的 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 文件中。我将其压缩并作为 zip 文件上传到创建 lambda 函数部分,但我不断收到此错误:
{
"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
是需要 () 和 handler
的文件是导出的函数。然后它应该可以使用相同的 zip 文件。
关于javascript - 从 zip 文件在 AWS 中创建 lambda 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30670957/