>我正在尝试为我的 Lambda 函数添加 2 个角色,购买我收到此错误:
iamRoleStatement应该是一个对象数组,其中每个对象都有效果,操作,资源字段。具体而言,语句 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
请注意,我使用的是无服务器 iam-roles-per-function,它允许为每个函数添加单独的角色。
我相信
您的问题是您在无服务器框架函数部分中使用了 Cloudformation 内部函数。
具体说来:
Resource:
Fn::GetAtt:
- imageLibraryTable
- Arn
和
Ressource:
Ref: DetectLabelTopic
您不想在这里使用内部函数,而是使用使用无服务器变量的 ARN
查看无服务器 iam 每个函数角色文档中的角色名称