Using Auto Scaling lifecycle hooks
As we just looked at the Auto Scaling lifecycle, there are two states when an instance enters these states that allow for extra actions to occur. These two states are the Pending state and the Terminating state. When a lifecycle hook is added to an ASG, there is a configurable amount of time set that an instance can wait before moving to the next state. In the case of the Terminating:Wait
state, you can have the instance pause for up to 30 minutes before moving on to the Terminating:Proceed
state and then on to Terminated
.
Use cases for lifecycle hooks
You may want to know some of the use cases for lifecycle hooks. Let's take a quick look at a few.
The first one is using the launching state to invoke a Lambda function. Once our instance has passed the pending state and gone on to the Pending:Wait
state, we can use this event to call a specific Lambda function for our application. A good use for this would be if we had Windows instances...