本文介绍了ec2实例终止时创建电子邮件通知.电子邮件中应包含实例详细信息.例如:实例名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为cloudtrail事件创建了cloudwatch警报.每当状态发生变化时,我都会收到电子邮件通知.但是,对于我来说很难在数百个实例中搜索被删除的实例.如果在通知电子邮件中获得实例名称,将会更容易.有人尝试过吗?

I have created cloudwatch alarms for cloudtrail events. I am getting the email notification whenever there is a state change. But It is tough for me to search for the instance which is deleted among hundreds of instances. It will be easier if I get the instance name in the notification Email. Have anyone tried this?

推荐答案

最好的方法是:

  • 创建 Amazon SNS主题以接收通知
  • 订阅该主题以接收通知(例如,通过电子邮件)
  • 在Amazon CloudWatch Events中创建规则,以在实例终止时触发:
  • Create an Amazon SNS topic to receive the notification
  • Subscribe to the topic to receive notifications (eg via Email)
  • Create a rule in Amazon CloudWatch Events to trigger when an instance is terminated:

结果将是通过电子邮件发送的类似这样的消息(或者您订阅了该主题):

The result will be a message like this sent via email (or however you subscribed to the topic):

{
    "version": "0",
    "id": "0c921724-d932-9cc2-b620-4053a0ad3f73",
    "detail-type": "EC2 Instance State-change Notification",
    "source": "aws.ec2",
    "account": "123456789012",
    "time": "2018-01-09T07:04:42Z",
    "region": "ap-southeast-2",
    "resources": [
        "arn:aws:ec2:ap-southeast-2:123456789012:instance/i-0a32beef35b8da342"
    ],
    "detail": {
        "instance-id": "i-0a32beef35b8da342",
        "state": "terminated"
    }
}

这篇关于ec2实例终止时创建电子邮件通知.电子邮件中应包含实例详细信息.例如:实例名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-30 01:50