multiple email subscription with cloud formation script

0

hi every one need help regarding cloud formation script I have created cloudformation script for alerts and which works fine I want to know how can I add multiple email address in this code if anyone knows and can help me will be thankful to him code his mention below

Parameters:
  sns:
    Type: String
    Default: Enter snstopic Name
    Description: Enter Your Sns Topic Name.
  EmailAdrs:
    Type: String
    Default: Enter Your Email Address
    Description: Enter Your Email Address.
  instancelist:
    Type: 'AWS::EC2::Instance::Id'
    Default: Select Your Instance
    Description: Select Your Instance from Dorpdown list.
  ThresHoldValue:
    Type: String
    Default: Enter ThresHold Value
    Description: Enter Value 100,90,80,70.
Resources:
  snstopic:
    Type: 'AWS::SNS::Topic'
    Properties:
      TopicName: !Ref sns
      Subscription:
        - Endpoint: !Ref EmailAdrs
          Protocol: email
  CloudWatchAlarm:
    Type: 'AWS::CloudWatch::Alarm'
    Properties:
      AlarmName: !Ref sns
      AlarmActions:
        - Ref: snstopic
      AlarmDescription: ES cluster CPU usage above 100%
      ComparisonOperator: GreaterThanThreshold
      TreatMissingData: notBreaching
      Dimensions:
        - Name: InstanceId
          Value: !Ref instancelist
      EvaluationPeriods: 1
      MetricName: CPUUtilization
      Namespace: AWS/ES
      Period: '60'
      Statistic: Sum
      Threshold: !Ref ThresHoldValue
2 Answers
1

There is a workaround, by using custom resources to define SNS and subscribing emails instead.

By using the Lambda function as a custom resource, you can subscribe multiple endpoints through an input parameter. You can use this Lambda function as a custom resource in any AWS CloudFormation template.

Please find it : https://docs.aws.amazon.com/prescriptive-guidance/latest/patterns/subscribe-multiple-email-endpoints-to-an-sns-topic-by-using-a-custom-resource.html

AWS
answered 9 months ago
0

The Subscription property of AWS::SNS::Topic resource accepts a list of subscriptions, so you can provide multiple subscriptions here (a list of Endpoint and Protocol combinations).

Alternatively, you can use AWS::SNS::Subscription resource type and then declare one for each email address that you need. This user guide contains sample template for an email endpoint https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-sns-subscription.html.

profile picture
joahna
answered 2 years ago
  • thanks for replying johna i did this but i want to add all address in online line with comma delemated without adding more endpoint

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions