3

For example, in a scenario where you have an auto-scaling group of size 1 that launches a spot instance which continually uses the same root EBS volume.

squillman
  • 37,883
  • 12
  • 92
  • 146
Derek Morrison
  • 213
  • 2
  • 6

2 Answers2

2

Not natively as far as I am aware, and not the root volume. You can however create a launch script to mount the volume as a secondary drive when the instance is spun up

keeganiden
  • 201
  • 1
  • 1
0

I don't think this can be done with autoscaling instances (the "cattle" service model).

But if you use a "pet" service model, you can now (since 2017) create a spot request and enable "Maintain target capacity" with "Interruption behavior: Stop" and a single availability zone. This way the root volume of the spot instance will be preserved even if it is temporarily interrupted.

I think (I did not check that) you can now convert a normal (pet-type) EC2 instance to a spot like this:

  • create spot instance with some public AMI,
  • stop the spot instance (possible since January 2020),
  • detach root volume from spot instance,
  • delete detached root volume,
  • stop the normal instance,
  • create snapshot of normal instance root volume, just in case,
  • detach root volume from normal instance,
  • attach root volume to spot instance,
  • terminate normal instance,
  • start spot instance.

There's also a script, ec2-spot-converter, that does something similar by creating a temporary AMI image:

Tometzky
  • 2,679
  • 4
  • 26
  • 32