无法使用SLS在本地调用AWS Lambda [英] Unable to invoke aws lambda locally using sls

查看:57
本文介绍了无法使用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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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