ec2实例创建和终止的SNS通知 [英] SNS notification for ec2 instance creation and termination
问题描述
每当在我的AWS账户中创建/终止ec2实例时,我都希望通过电子邮件收到通知。我该如何实现?
I would like to get notified via email, whenever an ec2 instance is created/terminated in my AWS account. How can I achieve this?
推荐答案
最简单的方法(IMO)是将CloudWatch Events服务与SNS一起使用主题配置为向您的电子邮件ID发送电子邮件。
The easiest method (IMO) to do that is to use CloudWatch Events service along with an SNS topic configured to send out emails to your email ID.
在AWS Web控制台中,转到CloudWatch->事件(在左侧面板上)->规则->'创建规则'
In AWS web console, go to CloudWatch -> Events (On left panel) -> Rules -> 'Create rule'
在事件源中选择事件模式。然后选择按服务分类的事件。在服务名称前面,选择 EC2,对于事件类型,选择 EC2实例状态更改通知。您可以选择任何州以获取每个州变更的通知,也可以选择您感兴趣的特定州(您可能会喜欢正在运行和已终止 |已停止)。在右侧,单击添加目标,然后从下拉列表中选择 SNS主题。然后选择一个已经配置为将通知电子邮件发送到您的电子邮件ID的SNS主题。
In 'Event Source' choose 'Event Pattern'. Then choose 'Events By Service'. In front of 'Service Name' select 'EC2' and for 'Event Type', select 'EC2 Instance State-change Notification'. You can either choose 'Any State' to get a notification on every state-change or choose specific state you are interested in ('Running' and 'Terminated'|'Stopped' might be of your interest). On the right, Click 'Add target' and then choose 'SNS topic' from dropdown. Then choose an SNS topic that you have configured already to send notification emails to your email ID.
希望这会有所帮助!
这篇关于ec2实例创建和终止的SNS通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!