通过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。现在尝试。