Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I stop a spot instance in aws just like I can stop and start an on demand ec2 instance

I had a use case where I was switching to using spot instances for my application instead of on demand instances. According to my requirement i should be able to stop that instance and restart it just the way we do it for on demand ec2-instances. In the aws console, i only found the option to reboot or terminate my instance and hovering over the stop option said "Spot instance cannot be stopped". Is there a workaround to allow stopping the instance or is it not possible as of now?

like image 436
TheShobhit147 Avatar asked Sep 06 '18 10:09

TheShobhit147


1 Answers

[Original: September 2018]

You yourself cannot stop a spot instance.

You can, however, specify that the interruption behavior for a spot instance is "stop" (instead of "terminate"). When an interruption event happens, your instance will be shut down and its state will be saved. When capacity is next available with your price/time requirements, AWS will restart your instance.

This feature is available for persistent Spot requests and Spot Fleets with the “maintain” fleet option enabled. You will not be charged for instance usage while your instance is stopped.

[Updated: February 2020]

Per announcement on Jan 13, 2020:

You can now stop your Amazon EC2 Spot Instances backed by Amazon EBS and start them at will, instead of relying on the “Stop” interruption behavior to stop your Spot Instances when interrupted. Earlier, you could only terminate your Spot Instances but now you can stop your Spot Instances and start them from the user initiated stop state provided Spot capacity is available within your maximum price requirements.

like image 89
jarmod Avatar answered Sep 20 '22 18:09

jarmod