AWS 无服务器 + 云形成:单函数部署时出错 - Windows 10 Env.



我有一个关于使用ServerlessCloud FormationAWS部署单个函数的问题。我正在使用Windows 10 - 64 bit作为操作系统。

环境:

Your Environment Information ---------------------------
Operating System:          win32
Node Version:              10.16.3
Framework Version:         1.52.1
Plugin Version:            3.0.0
SDK Version:               2.1.1

基本上,当我运行所有 AWS 环境(sls deploy -s dev(的经典部署时,一切正常。但是当我尝试部署一个我有更改的 Lambda 函数时,请使用以下命令:

sls deploy function -f MyLambdaFunc -s dev

我收到此错误:

TypeError: Cannot read property 'artifact' of undefined
at ServerlessPythonRequirements.BbPromise.bind.then.then.then (C:UsersuserDocumentscompanyclientAWS_environmentdeploymentnode_modulesserverless-python-requirementsindex.js:176:48)
From previous event:
at PluginManager.invoke (C:UsersuserAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:505:22)
at getHooks.reduce.then (C:UsersuserAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:540:24)
From previous event:
at PluginManager.run (C:UsersuserAppDataRoamingnpmnode_modulesserverlesslibclassesPluginManager.js:540:8)
at variables.populateService.then (C:UsersuserAppDataRoamingnpmnode_modulesserverlesslibServerless.js:115:33)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
at Serverless.run (C:UsersuserAppDataRoamingnpmnode_modulesserverlesslibServerless.js:102:74)
at serverless.init.then (C:UsersuserAppDataRoamingnpmnode_modulesserverlessbinserverless.js:67:28)
at C:UsersuserAppDataRoamingnpmnode_modulesserverlessnode_modulesgraceful-fsgraceful-fs.js:136:16
at C:UsersuserAppDataRoamingnpmnode_modulesserverlessnode_modulesgraceful-fsgraceful-fs.js:57:14
at FSReqWrap.args [as oncomplete] (fs.js:140:20)
From previous event:
at initializeErrorReporter.then (C:UsersuserAppDataRoamingnpmnode_modulesserverlessbinserverless.js:67:6)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:126:23)
From previous event:
at Object.<anonymous> (C:UsersuserAppDataRoamingnpmnode_modulesserverlessbinserverless.js:53:39)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

有人知道为什么吗?也许我在Windows 10上的npm安装有问题吗?

serverless.yml中更新您的函数:

your_function:
# ...
package: {}

然后sls deploysls deploy function -f your_function.

所以我发现新版本的无服务器(从1.52开始(存在问题,因此用户无法部署单个 lambda 函数。

基本上现在没有解决方案,除了回滚到1.51版本。

这里有一些细节:

https://github.com/serverless/serverless/issues/6752

我找到了解决方法,但我不确定副作用。

问题是无服务器python-requirements/index.js文件中的以下行(在我的版本中为#176行(:

arguments[1].functionObj && 
arguments[1].functionObj.package.artifact.

它只是假设在serverless.yml中的函数定义中存在package.artifact路径。

作为解决方法,我将"包:工件:"添加到我的函数中,如下所示,它起作用了:

hello:
handler: hello.handler
package:
artifact:
events:
- http:
path: hello
method: get

同样,我不确定这是否会破坏其他任何东西。我刚刚尝试了单个功能部署,它奏效了。但我没有做详细的测试。

相关内容

  • 没有找到相关文章

最新更新