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 個答案
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
已回答 10 個月前
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
已回答 2 年前
  • thanks for replying johna i did this but i want to add all address in online line with comma delemated without adding more endpoint

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南