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

Pass email address list to SNS subscription endpoint


Is it possible to pass a list of email addresses as the endpoint for an SNS subscription?

I've got something like this

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Resources" : {
      "EmailSNSTopic": {
        "Type" : "AWS::SNS::Topic",
        "Properties" : {
          "DisplayName" : "${display_name}"
        }
      },
      "MySubscription": {
        "Type": "AWS::SNS::Subscription",
        "Properties": {
          "TopicArn" : { "Ref" : "EmailSNSTopic" },
          "Endpoint" : "foo@foo.com"
          "Protocol" : "email"
        }
      }
    },
      "Outputs" : {
        "ARN" : {
          "Description" : "Email SNS Topic ARN",
          "Value" : { "Ref" : "EmailSNSTopic" }
        }
      }
}

But what I'd like to do is pass a number of email addresses instead of just one.


Solution

  • As per the documentation

    Endpoint should be a string

    Cloudformation doesn't allow you to pass a list.

    You dont want to have a custom resource as well.

    There is one more way Running bash commands in AWS CloudFormation templates

    You just run awscli command like below

        Resources:
        Command:
            Type: 'AWSUtility::CloudFormation::CommandRunner'
            Properties:
            Command: aws s3 ls > /command-output.txt
            Role: String
            LogGroup: String #Optional
            SubnetId: String #Optional
            SecurityGroupId: String #Optional
            KeyId: String #Optional