从创建压缩文件中的AWS lambda函数 [英] Creating a lambda function in AWS from zip file

查看:654
本文介绍了从创建压缩文件中的AWS lambda函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个简单的lambda函数,和我运行到一个错误。

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

我的code是基本

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文件,和我不断收到此错误:

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)"
  ]
}

任何人有什么想法?

Anyone have any ideas?

推荐答案

你的文件的名称需要的模块名称在处理程序配置相匹配。在这种情况下,您的处理程序应设置为 helloworld.handler ,其中的HelloWorld 是将需要的文件( )D和处理是导出的函数。然后,它应与同一个zip文件。

The name of your file needs to match the module name in the Handler configuration. In this case, your Handler should be set to helloworld.handler, where helloworld is the file that would be require()'d and handler is the exported function. Then it should work with the same zip file.

这篇关于从创建压缩文件中的AWS lambda函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆