【问题标题】:serverless - Type Error: Cannot read property 'Properties' of undefined无服务器 - 类型错误:无法读取未定义的属性“属性”
【发布时间】:2021-11-04 22:36:46
【问题描述】:

当发出serverless deploy --region eu-central-1 时,我得到了错误

 Type Error ---------------------------------------------
 
  Cannot read property 'Properties' of undefined
 
     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

此错误仅在包含后才开始

plugins:
  - serverless-iam-roles-per-function

并且可以通过注释掉插件来恢复。但我想用它来让我的 lambda 访问 DynamoDB。

除了this typo 之外,互联网上关于这个错误的消息相当空白。错误不是 solved by a recent update (yet) 并且 serverless 的通知没有多大帮助。 set SLS_DEBUG=*" 部署前:

 Type Error ----------------------------------------------

  TypeError: Cannot read property 'Properties' of undefined
      at ServerlessIamPerFunctionPlugin.createRoleForFunction (C:\Users\XXXXX\MyProject\node_modules\serverless-iam-roles-per-function\dist\lib\index.js:273:25)
      at ServerlessIamPerFunctionPlugin.createRolesPerFunction (C:\Users\XXXXX\MyProject\node_modules\serverless-iam-roles-per-function\dist\lib\index.js:383:18)
      at PluginManager.invoke (C:\snapshot\serverless\lib\classes\PluginManager.js:579:20)
      at async PluginManager.spawn (C:\snapshot\serverless\lib\classes\PluginManager.js:601:5)
      at async Object.before:deploy:deploy [as hook] (C:\snapshot\serverless\lib\plugins\deploy.js:60:11)
      at async PluginManager.invoke (C:\snapshot\serverless\lib\classes\PluginManager.js:579:9)
      at async PluginManager.run (C:\snapshot\serverless\lib\classes\PluginManager.js:639:7)
      at async Serverless.run (C:\snapshot\serverless\lib\Serverless.js:452:5)
      at async C:\snapshot\serverless\scripts\serverless.js:751:9

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

我应该在这篇文章中加入我的serverless.yml 吗?挺大的。

【问题讨论】:

    标签: aws-lambda serverless-framework serverless aws-serverless


    【解决方案1】:

    使用一些不同的关键词我检索到second (!) online search result,引用:

    插件不支持使用角色属性。您的提供者部分中有以下内容:角色:arn-for-deployment-role'。尝试删除它。

    More info here

    这基本上解决了这个问题,serverless-iam-roles-per-function 在注释掉这个后工作:

    provider:
      name: aws
      runtime: python3.7
      #iam: 
      #  role: CallsTableQueryRole
    

    原因可能是,以前的版本(无服务器

    provider:
      #previously:
      iam: 
        role:
          statements:
      #≥ v2.24.0
      iamRoleStatements:
    

    【讨论】:

      猜你喜欢
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 2022-11-12
      • 2017-08-12
      • 2018-04-29
      • 2018-02-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多