محاولة إنشاء قالب تشكيل سحابة مع سنز و سوس يعمل ، ولكن الرسائل لا تصل أبدا
-
26-12-2019 - |
سؤال
بعد الذهاب من خلال المستندات ، كتبت قالب تشكيل سحابة التالية لإنشاء موضوع سنز ، موضوع سوس والاشتراك في الموضوع إلى قائمة انتظار سوس:
{
"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"
}
]
}
}
}
}
يتم إنشاء سحابة تشكيل بنجاح ، ولكن كلما قمت بنشر رسالة إلى موضوع سنز ، وأنا فقط الحصول على البريد الإلكتروني ، الرسالة أبدا يصل إلى قائمة انتظار سوس.
أنا في عداد المفقودين شيء في السياسة هنا?هل هناك طريقة أخرى لاستخدام سحابة تشكيلات لادراك التعادل سنز و سكس?
المحلول
بعض الأشياء التي قد تساعد:
- لدي
"Resource": "*"
في سياسة قائمة الانتظار الخاصة بي. - لدي
ArnEquals
بدلا منStringEquals
على الCondition
(ولكن أعتقد أن هذا لا يهم). - يجب أن تكون قادرة على الابتعاد مع السماح فقط
"Action": ["sqs:SendMessage"]
.
نصائح أخرى
"Resource": {
"Ref": "CustomResourcesTopic"
},
إنه غير صحيح ، لأنه هنا يجب عليك استخدام قائمة الانتظار آرن
"Resource": {
"Fn::GetAtt": [
"CustomResourcesQueue",
"Arn"
]
},
وهذا الرمز أيضا أعتقد أنه من الخطأ
"Condition": {
"StringEquals": {
"aws:SourceArn": {
"Ref": "CustomResourcesTopic"
}
}
}
لأنه يجب عليك استخدام دي الموضوع آرن واستخدام "Ref": "CustomResourcesTopic"
سوف تحصل على اسم الموضوع
لذلك ، سيكون
"Condition": {
"StringEquals": {
"aws:SourceArn": "arn:aws:sns:{REGION}:{ACCOUNT_ID}:{TOPIC_NAME}"
}
}
لا تنتمي إلى StackOverflow