问题
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?
回答1:
[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.
回答2:
As of Jan 13, 2020, you can now do this: https://aws.amazon.com/about-aws/whats-new/2020/01/amazon-ec2-spot-instances-stopped-started-similar-to-on-demand-instances/
回答3:
You cant STOP/START Spot instance as similar to On-demand. below Link has enough info.,
"You can't stop and start an Amazon EBS-backed instance if it is a Spot Instance (only the Spot service can stop and start a Spot Instance), but you can reboot or terminate a Spot Instance)"
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/how-spot-instances-work.html
来源:https://stackoverflow.com/questions/52201821/can-i-stop-a-spot-instance-in-aws-just-like-i-can-stop-and-start-an-on-demand-ec