Detect EC2 spot termination and publish to SNS.
C#
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Properties
Setup
.gitattributes
.gitignore
App.config
LICENSE.md
MyTrace.cs
Program.cs
README.md
Service.Designer.cs
Service.cs
Service.resx
SpotStop2SNS.csproj
SpotStop2SNS.sln
WindowsServiceInstaller.cs
Worker.cs
packages.config

README.md

Windows Application/Service to detect spot instances terminations and publish to SNS for further customized notification for example sending emails or text.

##Summary

AWS notifies spot instances of imminent termination, for example due to the spot price exceding the requested max price, by means of instance meta data. When termination has been scheduled, this time is made available though an http request to http://169.254.169.254/latest/meta-data/spot/termination-time. This application will poll the url every 5 seconds. If termination is detected it will post a message to SNS, Amazon's Simple Notification Service. An admin can configure SNS the pick up on this message and take the appropriate actions, for example send an email or a text. Other applications subscribing to the topic will also be notified of the event.

Read more about Spot instance termination notices here.

Specifics

An SNS topic will automatically be created, if not existing. By default the topic is similar to arn:aws:sns:eu-west-1:860264074053:SpotInstanceTermination. Override this with

Credentials and region is specified through any means available by AWS .net sdk, for example

or using a credentials file:

##Command line

Just do

SpotStop2SNS.exe -Start

##Windows binaries and installer

An installer can be downloaded here which will install the application as a windows service.

##Related

Ec2spotstop2sns on Cosmik Debris.

If you'd like to debug this app locally, see the MockECSInstanceMetaData project.