无法使用SLS在本地调用AWS Lambda

编程入门 行业动态 更新时间:2024-10-09 13:25:05
本文介绍了无法使用SLS在本地调用AWS Lambda的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用sls框架来启动我的代码,直到今天,它仍能正常工作.未修改serverless.yml的配置,并且我尝试重新安装sls,但似乎无济于事.

Im using sls framework to launch my code and it was working fine until today. serverless.yml's configuration wasnt modified and ive tried reinstalling sls but nothing seems to work.

在抛出以下命令后,我的所有存储库都会出现以下消息: sls调用本地-f function_name --accountId $ accountId

The following message occurs for all my repos after throwing the following command: sls invoke local -f function_name --accountId $accountId

错误消息:

TypeError: Cannot read property 'Fn::ImportValue' of undefined at /usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:188:22 at Array.map (<anonymous>) at /usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:187:53 at tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23) at Function.Promise.attempt.Promise.try (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/method.js:39:29) at AwsInvokeLocal.loadEnvVars (/usr/local/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:154:25) at AwsInvokeLocal.tryCatcher (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:547:31) at Promise._settlePromise (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:604:18) at Promise._settlePromise0 (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:649:10) at Promise._settlePromises (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:729:18) at _drainQueueStep (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:93:12) at _drainQueue (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:86:9) at Async._drainQueues (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:102:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/local/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:15:14) at processImmediate (internal/timers.js:456:21) at process.topLevelDomainCallback (domain.js:137:15)```

推荐答案

我发现了问题所在.调用正在运行时发出警告:

I figured out what's wrong. There was a warning while the invocation was running:

Serverless Warning -------------------------------------- A valid environment variable to satisfy the declaration 'env:MY_API_KEY' could not be found.

因为这是一个警告,所以我只是忽略了它,它以前也起作用,但是显然框架现在不喜欢它.通过删除变量或定义变量来处理警告可以解决我的问题.

Since it was a warning I just ignored it and it previously worked but apparently the framework doesnt like it now. Dealing with the warning either by removing the variable or defining it resolved my issue.

更多推荐

无法使用SLS在本地调用AWS Lambda

本文发布于:2023-11-28 06:06:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1641231.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SLS   AWS   Lambda

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!