【问题标题】:"iamRoleStatements should be an array of objects" when trying to add multiple Roles to a Lambda function尝试将多个角色添加到 Lambda 函数时,“iamRoleStatements 应该是一个对象数组”
【发布时间】:2018-12-21 13:02:46
【问题描述】:

我正在尝试为我的 Lambda 函数添​​加 2 个角色购买我收到此错误:

iamRoleStatements 应该是一个对象数组,其中每个对象都有 Effect、Action、Resource 字段。具体来说,语句 1 缺少以下属性:资源

我的代码:

InsertImageDB:
  handler: index.lambda_handler
  module: InsertImageDB
  iamRoleStatements:
    - Effect: "Allow"
      Action:
        - dynamodb:Query
        - dynamodb:Scan
        - dynamodb:UpdateItem
        - dynamodb:GetItem
        - dynamodb:PutItem
      Resource:
        Fn::GetAtt:
          - imageLibraryTable
          - Arn

    - Effect: "Allow"
      Action:
        - sns:*
      Ressource:
        Ref: DetectLabelTopic

请注意,我使用的是 serverless-iam-roles-per-function,它允许为每个函数添加单独的角色。

【问题讨论】:

    标签: amazon-web-services serverless-framework


    【解决方案1】:

    我认为您的问题是您在无服务器框架 function section 中使用 Cloudformation intrinsic functions

    具体来说:

    Resource:
        Fn::GetAtt:
          - imageLibraryTable
          - Arn
    

    Ressource:
        Ref: DetectLabelTopic
    

    您不想在这里使用intrinsic functions,而是使用无服务器的ARN variables

    serverless-iam-roles-per-function docs 中查看role names

    【讨论】:

      猜你喜欢
      • 2023-03-05
      • 2014-04-21
      • 1970-01-01
      • 2020-08-05
      • 2023-03-28
      • 2021-04-12
      • 2013-01-24
      • 1970-01-01
      • 2013-11-03
      相关资源
      最近更新 更多