是否可以在 cloudformation 模板中创建具有多个电子邮件收件人的 SNS 主题?
Is to possible to create SNS topic with multiple email Recipients in cloudformation template?
V1:我正在尝试设置一个 cloudwatch 警报以向多个团队成员发送电子邮件通知。看起来我们只能在主题端点中设置一封电子邮件。有没有办法在 cloudformation 模板的端点中添加订阅者列表?还是有更好的方法来做到这一点?
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
问题:即使它有效,我的问题是,当您设置了多个 CloudWatch 警报并希望向其发送电子邮件通知时,什么是理想的方法某个阈值被突破时的多人?
在我看来,当您像这样对用户的每个电子邮件地址进行硬编码时,这有点违背了 cloudformation 模板的可重用性目的。即使我们将每个用户的电子邮件地址都参数化,当您有 50 subscribers/users 时,在参数文件中添加电子邮件地址也会花费很多时间。我可能是错的,或者有更好的方法来做到这一点!
谢谢!
CloudFormation 提供 AWS::SNS::Subscription 资源。
我不明白为什么你不能创建其中的一些,每个电子邮件收件人一个。
编辑。
对于两封电子邮件,您必须创建两个资源:
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
您可以使用
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
V1:我正在尝试设置一个 cloudwatch 警报以向多个团队成员发送电子邮件通知。看起来我们只能在主题端点中设置一封电子邮件。有没有办法在 cloudformation 模板的端点中添加订阅者列表?还是有更好的方法来做到这一点?
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
问题:即使它有效,我的问题是,当您设置了多个 CloudWatch 警报并希望向其发送电子邮件通知时,什么是理想的方法某个阈值被突破时的多人? 在我看来,当您像这样对用户的每个电子邮件地址进行硬编码时,这有点违背了 cloudformation 模板的可重用性目的。即使我们将每个用户的电子邮件地址都参数化,当您有 50 subscribers/users 时,在参数文件中添加电子邮件地址也会花费很多时间。我可能是错的,或者有更好的方法来做到这一点!
谢谢!
CloudFormation 提供 AWS::SNS::Subscription 资源。
我不明白为什么你不能创建其中的一些,每个电子邮件收件人一个。
编辑。
对于两封电子邮件,您必须创建两个资源:
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
您可以使用
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