Question

Difficulty: Very hardAuto Scaling and Elasticity

A SysOps administrator is configuring a launching lifecycle hook (`EC2_INSTANCE_LAUNCHING`) for an Amazon EC2 Auto Scaling group (ASG) integrated with an Application Load Balancer (ALB) target group. The administrator needs to ensure that custom software setup and patching are completed before instances receive traffic. Arrange the steps of the instance startup sequence in the correct chronological order from the initiation of the scale-out event to the instance serving active load-balanced traffic.

  1. 1The Auto Scaling group allocates a new EC2 instance, transitioning its state to `Pending`.
  2. 2The `EC2_INSTANCE_LAUNCHING` lifecycle hook triggers, pausing the launch process and placing the instance into the `Pending:Wait` state.
  3. 3The instance boots up and executes its custom user data script to download software patches and application binaries.
  4. 4A post-launch script calls the `CompleteLifecycleAction` API with the `CONTINUE` action token.
  5. 5The Auto Scaling group transitions the instance to `Pending:Proceed` and registers it with the Application Load Balancer (ALB) target group.
  6. 6The ALB target group health checks pass, and the Auto Scaling group transitions the instance to the `InService` state.

Answer

The correct sequence begins with the Auto Scaling group allocating a new instance and placing it into the `Pending` state. The lifecycle hook then immediately triggers, shifting the instance to `Pending:Wait`. While in this state, the instance boots up and runs its user data script. Once the script finishes, a call is made to `CompleteLifecycleAction` with the `CONTINUE` outcome. The instance then moves to `Pending:Proceed` and is registered with the ALB target group. Finally, the ALB health checks pass, and the instance is transitioned to the `InService` state.
The correct sequence ensures that the instance is allocated (`Pending`), paused (`Pending:Wait`), configured (user data runs), resumed via API (`CompleteLifecycleAction`), registered with the ALB (`Pending:Proceed`), and finally validated (`InService`). This order prevents premature routing of client traffic before configuration is complete.

Step-by-Step Solution

1
Initiate instance allocation and transition to the initial pending state.
The instance enters the `Pending` state.
This is the initial step in the Auto Scaling launch workflow.
2
Trigger the configured launching lifecycle hook to pause the startup process.
The instance enters the `Pending:Wait` state.
The lifecycle hook prevents the instance from moving forward in the workflow before configuration completes.
3
Run user data scripts on the booting EC2 instance.
Post-launch software installation and patching are completed on the instance.
The operating system boots up and runs user data while the Auto Scaling group holds the instance in the wait state.
4
Signal completion of the lifecycle action.
The `CompleteLifecycleAction` API is invoked with `CONTINUE`.
This notifies Auto Scaling that the custom configuration is complete and the launch workflow can resume.
5
Transition the instance out of the wait state and register it with the load balancer.
The instance moves to `Pending:Proceed` and is registered with the ALB target group.
Auto Scaling waits until the lifecycle hook is completed before registering the instance to prevent premature traffic routing.
6
Evaluate the health check status of the registered instance.
Health checks pass, and the instance enters the `InService` state.
Once marked healthy, the instance begins receiving active load-balanced client traffic.

Key Concept

Amazon EC2 Auto Scaling instance lifecycle hooks control the state transitions of newly launched instances, ensuring they execute configuration scripts and pass load balancer health checks before transitioning to the InService state.
Rate this question