Search code examples
amazon-web-servicesaws-cloudformationamazon-sns

create SNS topic in specific region


I am trying to create SNS topic in a specific region using cloudformation template.

SNSTopic:
    Type: AWS::SNS::Topic
    Properties: 
      FifoTopic: True
      TopicName: <topicname>.fifo

  SNSTopicPolicy:
    Type: AWS::SNS::TopicPolicy
    Properties:
      PolicyDocument:
        Version: 2012-10-17
        Statement:
          - Effect: Allow
            Principal:
              Service: 's3.amazonaws.com'
            Action: sns:Publish
            Resource: !Ref SNSTopic
            Condition:
              ArnEquals:
                aws:SourceArn: 'arn'
              StringEquals:
                aws:SourceAccount: <accountId>

I don't any parameter for mentioning region, where can I mention the region. I found for subscription I can mention the region for cross region resources but how do I create SNS topic in specific region using cloudformation template(yaml)


Solution

  • You'll need to create a stack set for your topic and specify the region in its StackInstancesGroup.

    You won't be able to use the stack set output, so you'll have to hardcode the topic ARN if you are going to use it in the main template.