Skip to content

Simple utility to send notifications for EC2 Instance Events

License

Notifications You must be signed in to change notification settings

kenXengineering/ec2EventNotifier

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EC2 Event Notifier

The EC2 Event Notifier is a simple utility that can send notifications for EC2 Events. An EC2 Event is a scheduled event by AWS, usually for alerting that an instance needs to be restarted or retired. This utility will look at all AWS EC2 instances and send a notification when an event is found.

The EC2 Event Notifier currently supports Slack Webhooks. To enable the Slack Webhook, start the application with the -slackWebHookURL flag.

Example:

ec2EventNotifyer -slackWebHookURL https://hooks.slack.com/services/...

The EC2 Event Notifier uses the native AWS SDK for Go. As such, it will look for either environment variables or the .config file setup with aws config.

Adding Additional Notifiers

You can add additional Notifiers, such as an E-Mail notifier, Pager Duty, etc. To create a new Notifier, it must implement the Notifier interface.

type Notifier interface {
    Notify(*ec2.InstanceStatus) error
}

The Notifier Interface has a single function Notify that takes in an EC2 Instance Status pointer. The EC2 Instance Status object holds the instance information as well as a slice of Events. The Notify function is responsible for creating the notification message and sending the notification.

To register a new Notifier, add an instance of it to the toNotify slice.

toNotify := make([]notifiers.Notifier, 0)

// Setup Slack Notifier
if slackWebHookURL != "" {
	log.Println("Enabling Slack Notifier")
	toNotify = append(toNotify, &notifiers.Slack{WebhookUR: slackWebHookURL})
}

Please see the Slack implementation found in notifiers/slack.go for an example of creating a Notifier.

About

Simple utility to send notifications for EC2 Instance Events

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published