简体   繁体   中英

How to add email subscription of SNS Topic on CloudFormation Script?

  TestTopicSubscription:
  Type: AWS::SNS::Subscription
  Properties:
    Endpoint: testn@email.com
    Protocol: email
    TopicArn: !Ref TestSnsTopic

How to add subscription for multiple email ids(eg:test1@email.com,test2@email.com) to the above list?

There are no loops in CloudFormation, and AWS::SNS::Subscription does not take any lists.

So your choices are:

  1. Use AWS CLI or SDK to programmatically create a number of stacks based on a single template. The template would be parameterized, where the parameter would be your endpoint. Thus, using bash or python, for instance, you would have to iterate over your list and create corresponding subscriptions.

  2. Creating a custom resource in CloudFormation to take your list of emails and create corresponding subscription. The resource would be in the form of a lambda function which would use AWS SDK to create needed subscriptions.

  3. Instead of custom resource, you could also create macro in CloudFormation.

  4. Manually copy-and-paste the subscriptions template, if you have only few of them in a single template.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM