【发布时间】: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