【问题标题】:How to prompt AWS SNS to send a confirmation message to a Cloudformation-created subscription?如何提示 AWS SNS 向 Cloudformation 创建的订阅发送确认消息?
【发布时间】:2018-09-29 07:02:39
【问题描述】:

通过 CloudFormation,我正在尝试创建一个队列并将其订阅到现有主题

$ cat ops/queue-and-subscription.yaml
AWSTemplateFormatVersion: 2010-09-09
Description: >-
  Minimal template

Resources:
  Queue:
    Type: 'AWS::SQS::Queue'

  Subscription:
    Type: 'AWS::SNS::Subscription'
    Properties:
      Endpoint:
        Fn::GetAtt:
          - "Queue"
          - "Arn"
      Protocol: "sqs"
      RawMessageDelivery: true
      TopicArn: "<existing Topic ARN>"

Outputs:
  QueueARN:
    Description: "ARN of the queue set up temporarily for testing"
    Value:
      Fn::GetAtt:
        - "Queue"
        - "Arn"
  QueueURL:
    Description: "URL of the queue. This is required for receiving messages"
    Value: !Ref Queue
$ aws cloudformation create-stack --stack-name my-test-stack --template-body file://ops/queue-and-subscription.yaml
{
    "StackId": "<stackId>"
}
[...wait...]
$ aws cloudformation describe-stacks --query 'Stacks[?StackName==`my-test-stack`] | [0].StackStatus'
"CREATE_COMPLETE"
$ aws cloudformation describe-stacks --query 'Stacks[?StackName==`my-test-stack`] | [0].Outputs[?OutputKey==`QueueURL`] | [0].OutputValue'
"<queueUrl>"
$ aws sqs receive-message --queue-url <queueUrl>
[null]

我希望确认消息会直接放入队列中(我需要读取并传递给 confirm-subscription 调用 docs。但是,从来没有这样的消息传递到队列。

如何提示 AWS(通过 SDK,而不是 UI)发送确认消息,以便我确认订阅?


编辑:我应该注意我刚刚尝试了类似的方法,但在模板中创建了 SNS 主题(并使用 !Ref Topic 引用它) - 相同的行为,没有确认消息。


EDIT2:我怀疑这是因为我没有提供SQS Queue Policy。现在试试。

【问题讨论】:

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


    【解决方案1】:

    一旦我添加了一个QueuePolicy 允许主题写入队列,消息就会按预期流过(没有确认消息)。

    【讨论】:

      猜你喜欢
      • 2023-03-10
      • 1970-01-01
      • 1970-01-01
      • 2018-07-19
      • 1970-01-01
      • 2016-02-13
      • 1970-01-01
      • 2017-12-22
      • 2016-04-03
      相关资源
      最近更新 更多