A SysOps administrator is troubleshooting an issue where an Amazon EC2 Auto Scaling group behind an Application Load Balancer (ALB) is registering new instances with the ALB before they are fully configured, leading to temporary HTTP 502 Bad Gateway errors. The administrator implements an `EC2_INSTANCE_LAUNCHING` lifecycle hook to pause the instance state during initialization. Arrange the sequence of operational steps and state transitions that must occur for a new instance to be successfully configured and start receiving healthy traffic from the ALB.
- 1Auto Scaling launches a new EC2 instance in response to a scale-out alarm.
- 2The instance begins booting and enters the Pending state.
- 3The EC2_INSTANCE_LAUNCHING lifecycle hook triggers, transitioning the instance to the Pending:Wait state.
- 4The instance runs its User Data script to complete software installation and configuration.
- 5A script on the instance calls the complete-lifecycle-action API with the CONTINUE result.
- 6Auto Scaling registers the instance with the ALB target group, transitioning the instance to InService after health checks pass.
Cevap
The correct order of steps starts with Auto Scaling launching the instance, transitioning it to the Pending state, pausing it via the launch lifecycle hook (Pending:Wait), executing the bootstrap scripts, completing the lifecycle action with a CONTINUE signal, and finally registering the instance with the Application Load Balancer target group to transition to the InService state.
The correct sequence ensures that the instance remains in a paused state (Pending:Wait) while configuration scripts run, preventing the load balancer from routing traffic to an unconfigured instance. The lifecycle hook must be completed using the API before Auto Scaling proceeds with load balancer registration and transitioning the instance to the InService state.
Adım Adım Çözüm
Anahtar Kavram
Auto Scaling Lifecycle Hooks and State Transitions
Tahmini Süre:2m 0s