An administrator is configuring a lifecycle hook (EC2_INSTANCE_TERMINATING) for an Amazon EC2 Auto Scaling group to back up application logs to an Amazon S3 bucket before instances are terminated. What is the correct chronological sequence of events starting from when the Auto Scaling group initiates the termination of an instance?
- 1The Auto Scaling group selects the instance for termination and puts it into the Terminating:Wait state.
- 2Amazon EventBridge detects the lifecycle transition and triggers the configured target, such as an AWS Lambda function.
- 3The target execution connects to the instance or runs a script to back up active logs to an Amazon S3 bucket.
- 4The target function invokes the CompleteLifecycleAction API call with a CONTINUE result to signal completion.
- 5The Auto Scaling group transitions the instance to the Terminating:Proceed state and terminates the EC2 instance.
Cevap
The correct sequence begins with the Auto Scaling group selecting the instance and transitioning it to the Terminating:Wait state. Next, Amazon EventBridge triggers a target function such as AWS Lambda. The target function performs the log backup to Amazon S3, and then calls the CompleteLifecycleAction API. Finally, the Auto Scaling group transitions the instance to the Terminating:Proceed state and terminates the instance.
The lifecycle hook flow requires that the Auto Scaling group first pauses termination (Terminating:Wait). This state change triggers EventBridge to invoke the cleanup script. Once the script backs up the logs to S3, it must call the CompleteLifecycleAction API with a CONTINUE result. The Auto Scaling group then changes the state to Terminating:Proceed and terminates the instance.
Adım Adım Çözüm
Anahtar Kavram
Auto Scaling Lifecycle Hooks