【问题标题】:Unable to create FIFO queue with dead letter queue in same cloudformation stack无法在同一 cloudformation 堆栈中创建具有死信队列的 FIFO 队列
【发布时间】:2019-02-20 23:52:44
【问题描述】:

我有一个包含 FIFO 队列及其相关死信队列的 cloudformation 堆栈。以前这不是 FIFO 队列,它部署得很好,首先建立了死信队列依赖,然后是“源队列”。将其切换到 FIFO 后,它不再起作用。我收到此错误:

"Template error: SQSQueue https://sqs.us-east-1.amazonaws.com/1234/dev-assignments-dlq doesn't exist",

所以看起来死信队列不再首先被创建。

 AWSTemplateFormatVersion: "2010-09-09"
    Resources:
      SourceQueue:
        Type: AWS::SQS::Queue
        Properties:
          FifoQueue: true
          QueueName: 'dev-push-notifications.fifo'
          RedrivePolicy:
            deadLetterTargetArn:
              Fn::GetAtt:
                - 'DeadLetterQueue'
                - 'Arn'
            maxReceiveCount: 5
          VisibilityTimeout: 30
      DeadLetterQueue:
        Type: AWS::SQS::Queue
        Properties:
          QueueName: 'dev-push-notifications-dlq'

【问题讨论】:

    标签: amazon-web-services amazon-cloudformation amazon-sqs


    【解决方案1】:

    原来死信队列必须和它的源是同一类型的。

    将 cloudformation 堆栈更改为此有效:

    AWSTemplateFormatVersion: "2010-09-09"
    Resources:
      SourceQueue:
        Type: AWS::SQS::Queue
        Properties:
          FifoQueue: true
          QueueName: 'dev-push-notifications.fifo'
          RedrivePolicy:
            deadLetterTargetArn:
              Fn::GetAtt:
                - 'DeadLetterQueue'
                - 'Arn'
            maxReceiveCount: 5
          VisibilityTimeout: 30
      DeadLetterQueue:
        Type: AWS::SQS::Queue
        Properties:
          FifoQueue: true
          QueueName: 'dev-push-notifications-dlq.fifo'
    

    【讨论】:

      【解决方案2】:

      这很奇怪,因为 Cloudformation 应该检测到 GetAtt 的依赖关系。您可以尝试使用DependsOn 属性显式声明它:

      AWSTemplateFormatVersion: "2010-09-09"
        Resources:
          SourceQueue:
            Type: AWS::SQS::Queue
            DependsOn: DeadLetterQueue
            Properties:
              # ...
      

      【讨论】:

      • 谢谢!这最终没有奏效,但是通过强制首先使用 DependsOn 创建 dlq,我收到一条错误消息,揭示了真正的原因:“死信队列必须与源队列类型相同”。请参阅下面的答案。
      • 酷!我很高兴它有所帮助,并感谢分享事业 - 我学到了一些新东西。
      猜你喜欢
      • 2017-09-14
      • 2021-10-07
      • 1970-01-01
      • 2013-11-15
      • 2010-10-04
      • 2015-04-21
      • 1970-01-01
      • 1970-01-01
      • 2015-01-14
      相关资源
      最近更新 更多