Question

Difficulty: HardAuto Scaling and Elasticity

A SysOps administrator is configuring a custom launch lifecycle hook for an Amazon EC2 Auto Scaling group (ASG) that is registered with an Application Load Balancer (ALB) target group. The lifecycle hook is designed to run an AWS Systems Manager (SSM) Run Command script to perform configuration tasks before the instance starts serving traffic. What is the correct chronological sequence of events for a successful instance scale-out process?

  1. 1The Auto Scaling group launches an EC2 instance, which transitions into the Pending state.
  2. 2The Auto Scaling group transitions the instance to the Pending:Wait state, pausing the launch process.
  3. 3Amazon EventBridge detects the lifecycle action and triggers the AWS Systems Manager (SSM) Run Command on the instance.
  4. 4The SSM agent executes the configuration script, which calls the complete-lifecycle-action API with a CONTINUE result.
  5. 5The Auto Scaling group transitions the instance to the InService state and registers it with the ALB target group.

Answer

The correct sequence starts with launching the instance into the Pending state, followed by pausing it in the Pending:Wait state via the lifecycle hook. Next, EventBridge detects the state change and triggers SSM Run Command. The SSM script runs and completes the lifecycle action using the CONTINUE result. Finally, the instance transitions to InService and registers with the ALB target group.
The correct sequence ensures that the EC2 instance is fully configured via Systems Manager Run Command before it is marked InService and registered with the ALB target group. This prevents the load balancer from forwarding user requests to an unconfigured instance. The flow is: Launch (Pending) -> Pause (Pending:Wait) -> Event Notification (EventBridge to SSM) -> Execution & Completion (SSM script calling complete-lifecycle-action) -> Finalization (InService and ALB registration).

Step-by-Step Solution

1
Identify the initial state change when an ASG scale-out is triggered.
The Auto Scaling group launches a new EC2 instance, which enters the Pending state.
All instances launched by an ASG start in the Pending state before lifecycle hooks are evaluated.
2
Determine where the launch lifecycle hook intercepts the lifecycle.
The instance transitions to the Pending:Wait state.
Launch lifecycle hooks pause the launch sequence specifically at the Pending:Wait transition.
3
Identify the mechanism that initiates the SSM Run Command.
Amazon EventBridge intercepts the Pending:Wait transition and invokes SSM Run Command.
EventBridge handles events indicating the instance is waiting in a lifecycle hook and routes them to automation targets.
4
Determine how the ASG is notified to resume the launch sequence.
The SSM agent runs the script, which calls the complete-lifecycle-action API.
The callback with the CONTINUE result tells the ASG that the custom launch configuration has completed successfully.
5
Identify the final status transition and registration.
The instance moves to the InService state and registers with the ALB target group.
Once the lifecycle hook is completed, the instance enters the InService state and begins registration to receive traffic.

Key Concept

Auto Scaling lifecycle hooks and event-driven automation workflow
Rate this question