Persistent Spot Instance Request with CloudFormation

amazon ec2amazon-cloudformationamazon-web-servicesautoscaling

Is it possible to create "Persistent Spot Instance" with AWS CloudFormation ?
I'm going through the Autoscale and EC2 CloudFormation's template references but there is no mention how to set a property so the Spot requests stay persistent.

When the price bid lower than the actual spot price AWS brings the instances down. I would like the instances to be started automatically when the instance price is cheaper again. This can be set manually when creating a new spot instance request by checking the option "Persistent Request" in the "Request Instances Wizard".

Best Answer

When using auto scaling, the spot requests are taken care of for you. Using auto scaling is like saying you want a persistent request. The auto scaling service makes new spot requests whenever your scaling policies are met, or whenever you're below desired capacity. If an instance comes down because your bid price is lower than current spot price, auto scaling will make another request once it senses that you're below desired capacity. Those requests are fulfilled when prices come below your bid.

To minimize downtime, I recommend setting the availability zones property in your auto scaling group to use all the availability zones in your region, since bidding for spot instances is on a per-availability zone basis. If one availability zone is currently above your bid (or down completely), another may be below, and the availability zone for your instance will be "swapped" with minimal downtime.