Soru

Zorluk: OrtaAuto Scaling and Elasticity

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?

  1. 1The Auto Scaling group selects the instance for termination and puts it into the Terminating:Wait state.
  2. 2Amazon EventBridge detects the lifecycle transition and triggers the configured target, such as an AWS Lambda function.
  3. 3The target execution connects to the instance or runs a script to back up active logs to an Amazon S3 bucket.
  4. 4The target function invokes the CompleteLifecycleAction API call with a CONTINUE result to signal completion.
  5. 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

1
Select and pause the instance.
The instance goes into the Terminating:Wait state, which pauses the termination.
This state transition allows custom actions to run before the instance is shut down.
2
Detect transition and trigger automation.
Amazon EventBridge catches the event and invokes the target Lambda function.
EventBridge orchestrates the event-driven notification of the lifecycle transition.
3
Execute cleanup scripts.
Logs are transferred to the Amazon S3 bucket.
The task must occur while the instance is still fully operational in the wait state.
4
Signal lifecycle completion.
The CompleteLifecycleAction API is called with the CONTINUE result.
This informs the Auto Scaling group that the custom action is finished.
5
Terminate the instance.
The instance moves to Terminating:Proceed and is shut down.
The Auto Scaling group resumes the termination workflow after the signal is received.

Anahtar Kavram

Auto Scaling Lifecycle Hooks
Bu soruyu puanla