SQS订阅SNS:如何在CloudFormation中指定多个TopicArns?

发布于 2025-01-14 14:39:03 字数 2119 浏览 1 评论 0原文

另一个团队创建了多个 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"
            }
          }
        }
    }
}

How can Ispecify multiple TopicArns in one "AWS::SNS::Subscription"以避免重复。

我尝试在参数中使用通配符

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

,但它错误地显示为无效 ARN。

A different team has created several SNS topics to work around the SNS quotas. The ARNs are

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

I am trying to subscribe an SQS to these topics. My CloudFormation looks like below, with lots of duplication:

{
    "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"
            }
          }
        }
    }
}

How can I specify multiple TopicArns in one "AWS::SNS::Subscription" to avoid duplication.

I tried using wild cards in the parameters

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

but it errors out as invalid ARN.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

情话难免假 2025-01-21 14:39:03

除非您要开发自己的 自定义资源模板宏为此。

There is no such way unless you are going to develop your own custom resource or template macro for that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文