---
AWSTemplateFormatVersion: '2010-09-09'
Description: Handel-created SNS topic

Resources:
  Topic:
    Type: AWS::SNS::Topic
    Properties: 
      DisplayName: {{topicName}}
      TopicName: {{topicName}}
  {{#if subscriptions}}
  {{#each subscriptions}}
  Subscription{{@index}}:
    Type: AWS::SNS::Subscription
    Properties:
      Endpoint: {{endpoint}}
      Protocol: {{protocol}}
      TopicArn: !Ref Topic
  {{/each}}
  {{/if}}

Outputs:
  TopicArn:
    Description: The ARN of the topic
    Value: !Ref Topic
  TopicName:
    Description: The name of the topic
    Value: 
      Fn::GetAtt: 
        - "Topic"
        - "TopicName"
