SNSとSQSの作品を使用してクラウドフォーミングテンプレートを作成しようとしていますが、メッセージは到着しませんでした
-
26-12-2019 - |
質問
ドキュメントを経て、次のクラウドフォーメーションテンプレートを作成してEN SNSトピック、SQSトピックを作成し、トピックをSQSキューに購読する:
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Creates the SNS topic, SQS queue and instance that will service the custom resources queue",
"Parameters": {
"Environment": {
"Description": "Environment in which to manage queues",
"Type": "String",
"Default": "qa",
"AllowedValues": [ "development", "qa", "staging", "production"]
},
"EmailAddress": {
"Description": "Email to where notifications will be sent",
"Type": "String",
"Default": "example@email.com"
}
},
"Resources": {
"CustomResourcesQueue": {
"Type": "AWS::SQS::Queue",
"Properties": {
"ReceiveMessageWaitTimeSeconds": 20,
"VisibilityTimeout": 60,
"QueueName": {
"Fn::Join": ["-", ["cloud_formation_custom_resources", {
"Ref": "Environment"
}]]
}
}
},
"CustomResourcesTopic": {
"Type": "AWS::SNS::Topic",
"Properties": {
"Subscription": [
{
"Endpoint": {
"Ref": "EmailAddress"
},
"Protocol": "email"
},
{
"Endpoint": {
"Fn::GetAtt": ["CustomResourcesQueue", "Arn"]
},
"Protocol": "sqs"
}
]
}
},
"SNSToSQSPolicy": {
"Type": "AWS::SQS::QueuePolicy",
"Properties": {
"PolicyDocument": {
"Id": "PushMessageToSQSPolicy",
"Version": "2012-10-17",
"Statement": [
{
"Sid": "allow-sns-to-send-message-to-sqs",
"Effect": "Allow",
"Action": [ "sqs:*" ],
"Principal": {
"AWS": "*"
},
"Resource": {
"Ref": "CustomResourcesTopic"
},
"Condition": {
"StringEquals": {
"aws:SourceArn": {
"Ref": "CustomResourcesTopic"
}
}
}
}
]
},
"Queues": [
{
"Ref": "CustomResourcesQueue"
}
]
}
}
}
}
.
クラウド形成は正常に作成されますが、SNSトピックにメッセージを公開するたびに、電子メールを入手するだけで、メッセージはSQSキューに到着しません。
私はここで政策に何かが足りないですか?SNSとSQSを結ぶためにクラウドフォームを使用する方法は他にありますか?
解決
助けるかもしれないことがいくつかあります:
- 私のキューポリシーに
"Resource": "*"
を持っています。 -
ArnEquals
のStringEquals
の代わりにCondition
を持っています(ただし、それは問題ではないと思います)。 -
"Action": ["sqs:SendMessage"]
だけを許可することを避けることができるはずです。
他のヒント
"Resource": {
"Ref": "CustomResourcesTopic"
},
.
誤っているので、ここではキューARN
を使用する必要があります。"Resource": {
"Fn::GetAtt": [
"CustomResourcesQueue",
"Arn"
]
},
.
とこのコードも間違っていると思います
"Condition": {
"StringEquals": {
"aws:SourceArn": {
"Ref": "CustomResourcesTopic"
}
}
}
.
DEトピックARNを使用し、"Ref": "CustomResourcesTopic"
を使用する必要があるため、DE TopicName
だから、それは
になります"Condition": {
"StringEquals": {
"aws:SourceArn": "arn:aws:sns:{REGION}:{ACCOUNT_ID}:{TOPIC_NAME}"
}
}
. 所属していません StackOverflow