You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

CloudFormation:如何在SQS策略条件中添加多个Event Rule ARN

问题解决:CloudFormation SQS队列策略添加多个Event Rule ARN

错误原因

你当前的写法错误地将两个资源名塞进了单个Fn::GetAtt调用中,而Fn::GetAtt要求必须是单个资源名+单个属性名的组合,这就是触发报错的直接原因。

正确配置方式

要允许多个Event Rule的ARN向SQS发送消息,只需在ArnEquals条件中传入包含两个ARN的数组,每个ARN通过单独的Fn::GetAtt获取即可:

DlqSqsQueuePolicy:
  Type: AWS::SQS::QueuePolicy
  Properties:
    PolicyDocument:
      Statement:
        - Action: sqs:SendMessage
          Condition:
            ArnEquals:
              aws:SourceArn:
                - !GetAtt ExistingEventRule.Arn
                - !GetAtt NewEventRule.Arn
          Effect: Allow
          Principal:
            Service: events.amazonaws.com
          Resource: !GetAtt DlqSqsQueue.Arn

如果偏好使用完整的Fn语法,也可以写成:

DlqSqsQueuePolicy:
  Type: AWS::SQS::QueuePolicy
  Properties:
    PolicyDocument:
      Statement:
        - Action: sqs:SendMessage
          Condition:
            ArnEquals:
              aws:SourceArn:
                - Fn::GetAtt:
                    - ExistingEventRule
                    - Arn
                - Fn::GetAtt:
                    - NewEventRule
                    - Arn
          Effect: Allow
          Principal:
            Service: events.amazonaws.com
          Resource: !GetAtt DlqSqsQueue.Arn

补充说明

  • 务必配置Principal为events.amazonaws.com,明确授权事件服务作为发送消息的主体,否则策略会无效
  • ArnEquals条件天然支持数组形式的多个值,这样就能同时授权现有规则和新规则向目标SQS队列发送消息

内容的提问来源于stack exchange,提问作者Jatin Mehrotra

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 08:20:43