During an automated scale-in event, a SysOps administrator needs to understand the exact lifecycle of an Amazon EC2 instance within an Auto Scaling group. The group is registered with an Application Load Balancer (ALB) target group and is configured with an `EC2_INSTANCE_TERMINATING` lifecycle hook. Arrange the following events in the correct chronological order from the start of the scale-in event to the final termination of the instance.
- 1The Auto Scaling group selects the specific EC2 instance to terminate based on the configured termination policy.
- 2The instance state transitions to `Terminating`, and the Application Load Balancer begins the deregistration delay (connection draining) process.
- 3The `EC2_INSTANCE_TERMINATING` lifecycle hook triggers, transitioning the instance state to `Terminating:Wait`.
- 4A custom log-collection script runs on the instance, and the lifecycle action is completed with a `CONTINUE` status.
- 5The instance state transitions to `Terminating:Proceed`, and the instance is terminated once the deregistration delay expires.
Answer
First, the Auto Scaling group selects the EC2 instance for termination based on the configured termination policy. Next, the instance state transitions to `Terminating`, and the Application Load Balancer begins the deregistration delay (connection draining). Third, the `EC2_INSTANCE_TERMINATING` lifecycle hook triggers, transitioning the instance to the `Terminating:Wait` state. Fourth, a custom log-collection script runs, and the lifecycle action is completed with a `CONTINUE` status. Finally, the instance transitions to `Terminating:Proceed` and is shut down and terminated after both the lifecycle action and deregistration delay complete.
The correct chronological sequence of events during a scale-in lifecycle event begins with the Auto Scaling group selecting the instance to terminate based on the group's termination policy. Once selected, the instance transitions to the `Terminating` state, which immediately triggers the Application Load Balancer to begin the deregistration delay (connection draining). Simultaneously, the scale-in lifecycle hook is triggered, shifting the instance state to `Terminating:Wait`. In this wait state, custom scripts (such as log backup) are executed. Once finished, a `complete-lifecycle-action` command is sent with a `CONTINUE` parameter, moving the instance to `Terminating:Proceed`. Finally, once both the lifecycle hook is completed and the deregistration delay has elapsed, the instance is terminated.
Step-by-Step Solution
Key Concept
Auto Scaling Instance Lifecycle and Integration with ELB Deregistration Delay and Lifecycle Hooks