简体   繁体   English

是否可以在 cloudformation 模板中使用多个 email 收件人创建 SNS 主题?

[英]Is to possible to create SNS topic with multiple email Recipients in cloudformation template?

V1: I am trying to set up a cloudwatch alarms to send email notification to the multiple team members. V1:我正在尝试设置一个 cloudwatch 警报,以向多个团队成员发送 email 通知。 it looks like we can only set one email in the topic endpoint.看起来我们只能在主题端点中设置一个 email。 is there any way to add list of subscribers in the endpoint in the cloudformation template?有没有办法在 cloudformation 模板的端点中添加订阅者列表? or is there any better approach to do this?还是有更好的方法来做到这一点?

V2: when I created SNS::Subscription resource and provide 2 emails, it gave me error: ##[error]Error: Stack failed to reach update completion status, error: 'Resource is not in the state stackUpdateComplete' I am not sure if I have provided property in a right format or what could be the mistake. V2:当我创建 SNS::Subscription 资源并提供 2 封电子邮件时,它给了我错误:##[error]Error: Stack failed to reach update completion status, error: 'Resource is not in the state stackUpdateComplete' 我不确定如果我以正确的格式提供财产或者可能是什么错误。

Resources:
  Topic:
    Type: "AWS::SNS::Topic"
    Properties:
      DisplayName: !Sub "Connect InstanceId ${InstanceId}"

  EmailSubscription:
    Type: AWS::SNS::Subscription
    Properties:
      Endpoint: abc@abc.com
      Protocol: email
      Endpoint: xyz@xyz.com
      Protocol: email
      TopicArn: !Ref Topic

Question : even though if it works, My question regarding to this is, what would be ideal approach when you have set up multiple CloudWatch Alarms and want to send email notification to the multiple people when certain threshold is breach?问题:即使它有效,我的问题是,当您设置了多个 CloudWatch 警报并希望在违反某个阈值时向多人发送 email 通知时,什么是理想的方法? The way I see it, it is kind of defeating the purpose of re usability of cloudformation template when you hard-code every email address of users like this.在我看来,当您像这样对用户的每个 email 地址进行硬编码时,这有点违背了 cloudformation 模板的可重用性目的。 and even if we parameterize email address of every users, it would take a lot of time to add email address in the parameter file when you have 50 subscribers/users.即使我们参数化每个用户的 email 地址,当您有 50 个订阅者/用户时,在参数文件中添加 email 地址也会花费很多时间。 I could be wrong or is there any better approach to do this!我可能是错的,或者有更好的方法来做到这一点!

Thanks!谢谢!

The CloudFormation provides a AWS::SNS::Subscription resource. CloudFormation 提供AWS::SNS::Subscription资源。

I don't see any reason why you couldn't create few of them, one for each of your email recipients .我看不出有什么理由不能创建几个,每个 email 收件人一个

Edit.编辑。

For two emails, you have to create two resources :对于两封电子邮件,您必须创建两个资源

 EmailSubscription1:
    Type: AWS::SNS::Subscription
    Properties:
      Endpoint: abc@abc.com
      Protocol: email
       TopicArn: !Ref Topic

 EmailSubscription2:
    Type: AWS::SNS::Subscription
    Properties:
      Endpoint: xyz@xyz.com
      Protocol: email
      TopicArn: !Ref Topic

You can use您可以使用

Resources:
  Topic:
    Type: "AWS::SNS::Topic"
    Properties:
      DisplayName: !Sub "Connect InstanceId ${InstanceId}"
      Subscription:
        - Endpoint: <email_1>
          Protocol: "email"
        - Endpoint: <email_2>
          Protocol: "email"
EmailSubscription: 
  Type: AWS::SNS::Topic
  Properties: 
    Subscription: 
      - Endpoint: "xyz@xyz.com"
        Protocol: "email"
      - Endpoint: "abc@abc.com"
        Protocol: "email"
    TopicName: !Ref Topic                                                            

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 CloudFormation 脚本上添加 email 订阅 SNS 主题? - How to add email subscription of SNS Topic on CloudFormation Script? AWS SNS 主题策略 Cloudformation - AWS SNS Topic Policy Cloudformation 用于创建多个 SQS 的 Cloudformation 模板 - Cloudformation template to create multiple SQS 使用CDK,SNS主题Policy Statement,使用actions:["sns:*"],Cloudformation导致“Policy statement action out of service scope!” - Using CDK, SNS topic Policy Statement, use actions: ["sns:*"], Cloudformation results in "Policy statement action out of service scope!" 我可以创建对 AWS SNS 主题的 Slack 订阅吗? - Can I create Slack subscriptions to an AWS SNS topic? 订阅单个 SQS 到两个/多个 SNS 主题的优缺点 - Pros and cons of subscribing single SQS to two/multiple SNS topic SNS 主题可以成为 EventBridge 的来源吗? - Can SNS Topic be a source to EventBridge? 是否可以在 azure function 应用程序中创建主题订阅? - Is it possible to create a topic subscription in an azure function app? 从 CloudFormation 模板中的 DropDownList 选择多个值 - Selecting multiple values from DropDownList in CloudFormation Template 用于多个参数文件和单个模板的 CloudFormation - CloudFormation for multiple parameter files and a single template
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM