繁体   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