如何在Cloudformation中为AWS::Lambda::Permission提供多个SourceArn?

huangapple go评论57阅读模式
英文:

How to give multiple SourceArn for AWS::Lambda::Permission in Cloudformation?

问题

I have updated the template.yaml file as below, I need to give permission to multiple schedulers for a lambda function.

## Grant permission to Events trigger Lambda
PermissionForEventsToInvokeSchedulerFunction:
  Type: AWS::Lambda::Permission
  Properties:
    FunctionName: !Ref SchedulerFunction
    Action: lambda:InvokeFunction
    Principal: events.amazonaws.com
    SourceArn: 
      - !GetAtt AsyncDashboardFirstDayMonthScheduledRule.Arn
      - !GetAtt AsyncDashboardOnceEveryDayScheduledRule.Arn
      - !GetAtt AsyncDashboardOnceEveryOnehourScheduledRule.Arn

Getting error below.

Value of property SourceArn must be of type String.

英文:

I have updated the template.yaml file as below, I need to give permission to multiple schedulers for an lambda function.

  ## Grant permission to Events trigger Lambda
  PermissionForEventsToInvokeSchedulerFunction:
    Type: AWS::Lambda::Permission
    Properties:
      FunctionName: !Ref SchedulerFunction
      Action: lambda:InvokeFunction
      Principal: events.amazonaws.com
      SourceArn: 
        - !GetAtt AsyncDashboardFirstDayMonthScheduledRule.Arn
        - !GetAtt AsyncDashboardOnceEveryDayScheduledRule.Arn
        - !GetAtt AsyncDashboardOnceEveryOnehourScheduledRule.Arn

Getting error below.

Value of property SourceArn must be of type String

答案1

得分: 2

如果您查看AWS文档的SourceArn,您会发现这是一个字符串,而不是一个字符串列表。因此,您只能在SourceArn中有一个值。

英文:

If you check aws docs's SourceArn you will see that this is a string, not a list of strings. So you can have only one value in SourceArn.

huangapple
  • 本文由 发表于 2023年4月4日 03:52:37
  • 转载请务必保留本文链接:https://go.coder-hub.com/75923296.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定