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?
- 1The Auto Scaling group launches an EC2 instance, which transitions into the Pending state.
- 2The Auto Scaling group transitions the instance to the Pending:Wait state, pausing the launch process.
- 3Amazon EventBridge detects the lifecycle action and triggers the AWS Systems Manager (SSM) Run Command on the instance.
- 4The SSM agent executes the configuration script, which calls the complete-lifecycle-action API with a CONTINUE result.
- 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
Key Concept
Auto Scaling lifecycle hooks and event-driven automation workflow