Auto Scaling instance refresh: healthy percentage, rollback
The EC2 Auto Scaling User Guide says an instance refresh replaces instances in batches set by the minimum and maximum healthy percentages of desired capacity. The defaults without an instance maintenance policy are 90 and 100 percent. A refresh can be rolled back only while it is in progress; afterwards you start a new refresh.
How do the healthy percentages control the batches?
The minimum healthy percentage is the share of desired capacity that must stay in service and healthy for the refresh to continue. The maximum healthy percentage is how far above desired capacity the group may grow while replacing. The difference between them cannot exceed 100.
With 90 and 100, 10 percent of capacity is replaced at a time and the group never grows. With both at 100, the refresh launches a new instance before terminating an old one, one at a time, so capacity never falls below desired. A minimum of 0 replaces everything at once.
After a new instance passes health checks, the refresh waits for the instance warmup before it moves on. If an instance maintenance policy is set on the group, the percentages come from it unless you override them.
What do bake time, checkpoints and skip matching do?
Bake time is a wait at the end of the refresh before it counts as complete. Its default is zero. Checkpoints pause the refresh after set percentages so you can verify; the default delay is one hour and they are off by default.
Skip matching leaves alone instances that already match the desired configuration. It is on by default in the console and off by default with the AWS CLI or an SDK.
When the refresh succeeds, Auto Scaling updates the group's settings to the desired configuration. During the refresh, any scale-out launches instances with the desired configuration.
When can you roll back?
You can roll back a refresh that is still in progress. You cannot roll it back after it has finished; to go back then, start a new instance refresh with the old configuration.
Rollback needs a desired configuration in the refresh, and the launch template version must be a specific number. It is not available with $Latest or $Default.
Auto rollback is off by default. With it on, the refresh reverses itself when it fails or when a CloudWatch alarm you named goes into ALARM. If you name an alarm without enabling auto rollback, the refresh fails without rolling back. The alarm only matters while the refresh is running, which is why a bake time keeps the window open after the last replacement.
Where the exam catches people
Trying to roll back a finished instance refresh: rollback exists only while the refresh is in progress. Start a new refresh instead.
Believing the default refresh launches before it terminates: that happens only when the minimum healthy percentage is 100.
Expecting an alarm to trigger rollback after the last instance is replaced: with the default bake time of zero the refresh is already complete.
Using $Latest in the group and expecting rollback: rollback needs a specific numbered launch template version.
Attaching an alarm and assuming rollback follows: without auto rollback enabled the refresh only fails.