awslabs / ec2-spot-labs

Collection of tools and code examples to demonstrate best practices in using Amazon EC2 Spot Instances.
https://aws.amazon.com/ec2/spot/
Other
946 stars 320 forks source link

Add Spot Interruption Handler #40

Closed ivallhon closed 4 years ago

ivallhon commented 4 years ago

Description of changes: This PR adds a Spot Interruption Handler sample project to react to EC2 Spot interruptions of instances running on an Auto Scaling group or a Spot Fleet. Instances must have a tag for the handler to take actions on them. If the instance is part of an ASG, it calls the DetachInstances API to put the instance in draining state and attempt launching replacement capacity. Optionally, the handler executes commands on the instance using AWS Systems Manager Run Command. The commands to be executed are set on Parameter Store within AWS Systems Manager.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

schmutze commented 4 years ago

Thanks @ivallhon !