簡體   English   中英

SQS訂閱SNS:如何在CloudFormation中指定多個TopicArns?

[英]SQS subscribing to SNS: How to specify multiple TopicArns in CloudFormation?

另一個團隊創建了多個 SNS 主題來解決 SNS 配額問題。 ARN 是

arn:aws:sns:us-west-1:xxxx:SomeTopic.fifo
arn:aws:sns:us-west-1:xxxx:SomeTopic1.fifo
arn:aws:sns:us-west-1:xxxx:SomeTopic2.fifo
...
arn:aws:sns:us-west-1:xxxx:SomeTopicN.fifo

我正在嘗試為這些主題訂閱 SQS。 我的 CloudFormation 如下所示,有很多重復項:

{
    "AWSTemplateFormatVersion" : "2010-09-09",
    "Parameters"               : {
        "SomeTopicArn" : {
            "Type" : "String",
            "Default" : "arn:aws:sns:us-west-1:xxxx:SomeTopic.fifo"
        },
        "SomeTopicArn1" : {
            "Type" : "String",
            "Default" : "arn:aws:sns:us-west-1:xxxx:SomeTopic1.fifo"
        }
    },
    "Resources"                : {
        "SomeQueue" : {
            "Type" : "AWS::SQS::Queue",
            "Properties" : {
                "QueueName" : "SomeQueue.fifo",
                "FifoQueue"                     : "true"
            }
        },
        "SubscribeSomeQueueSqsToSomeTopic" : {
            "Type" : "AWS::SNS::Subscription",
            "Properties" : {
                "Protocol" : "sqs",
                "Endpoint" : {
                    "Fn::GetAtt" : [
                        "SomeQueue",
                        "Arn"
                    ]
                },
                "TopicArn" : {
                    "Ref" : "SomeTopicArn"
                }
            }
        },
        "SubscribeSomeQueueSqsToSomeTopic1" : {
          "Type" : "AWS::SNS::Subscription",
          "Properties" : {
            "Protocol" : "sqs",
            "Endpoint" : {
              "Fn::GetAtt" : [
                "SomeQueue",
                "Arn"
              ]
            },
            "TopicArn" : {
              "Ref" : "SomeTopicArn1"
            }
          }
        }
    }
}

如何在一個“AWS::SNS::Subscription”中指定多個 TopicArns 以避免重復。

我嘗試在參數中使用通配符

"Parameters"               : {
        "SomeTopicArn" : {
            "Type" : "String",
            "Default" : "arn:aws:sns:us-west-1:xxxx:SomeTopic*.fifo"
        },

但它會錯誤地顯示為無效 ARN。

除非您要為此開發自己的自定義資源模板宏,否則沒有這種方法。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM