2 min read | by Jordi Prats
When running spot instances, if AWS needs to reclaim that capacity (or if the current Spot price exceeds our bid price) we will receive a two minutes grace period to be able to save any data we need.
To check is we need to terminate our tasks on the spot instance we can use the instance's metadata
We have several endpoints to use, all of them will return and HTTP 404 response until the instance is going to be interrupted. We can use:
For as long as any of these paths return a 404 we can continue using the instance, but as soon as we get a 200 we will have approximately two minutes to prepare for it to be terminated
# curl -I http://169.254.169.254/latest/meta-data/spot/termination-time HTTP/1.1 404 Not Found Content-Length: 0 Date: Mon, 23 May 2022 15:48:19 GMT Server: EC2ws Connection: close Content-Type: text/plain
Posted on 24/05/2022