[英]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.