Reputation: 250
I am using cloudformation UpdatePolicy attribute to perform a rolling update in case of any change to my ec2 launch configuration. This works fine while using on demand instances. But when I use spot instances I get below error:
Autoscaling rolling updates cannot be performed because the current launch configuration is using spot instances and MinInstancesInService is greater than zero.
Setting MinInstancesInService
property to zero make it work but then I get around 3-5 min downtime.
Is there a way to achieve this without the downtime using Cloudformation? If not can someone point towards a better way to automate this rolling update process as I have multiple environments and doing it manually is very error prone. Thanks
Upvotes: 2
Views: 1515
Reputation: 9837
You cannot set MinInstancesInService
to anything other than 0 when using spot instances, because spot instances can be terminated at any time, thus making it impossible for AWS to guarantee a minimum number of instances to be kept in service during the rolling update.
However, you can set the MaxBatchSize
param in your UpdatePolicy to 1, so only one instance will be updated at a time. To ensure high availability, you must make sure there are 2 or more instances available in your AutoScalingGroup, otherwise the rolling update will terminate your single instance, resulting in downtime.
Upvotes: 5