A company has an Amazon EC2 Auto Scaling group (ASG) configured with a scale-in lifecycle hook. When a scale-in event occurs, application log files on the instance must be backed up to an Amazon S3 bucket before the instance is terminated. A SysOps administrator is configuring this flow using Amazon EventBridge and AWS Systems Manager Run Command.
Arrange the sequence of events in the correct chronological order from the initiation of the scale-in event to the final termination of the instance.
- 1Auto Scaling determines a scale-in is required and selects an EC2 instance for termination based on the termination policy.
- 2Auto Scaling puts the instance into the Terminating:Wait status, pausing the termination process.
- 3An Amazon EventBridge rule detects the Terminating:Wait lifecycle action event and invokes an AWS Systems Manager Run Command document.
- 4The Systems Manager Run Command script executes on the target instance, copying local log files to the Amazon S3 bucket.
- 5The script invokes the complete-lifecycle-action AWS CLI command with the CONTINUE result to notify Auto Scaling.
- 6Auto Scaling transitions the instance to the Terminating:Proceed state and terminates the EC2 instance.
Answer
The correct sequence starts with Auto Scaling selecting the instance for termination. Next, the instance enters the Terminating:Wait state, which triggers an Amazon EventBridge rule to invoke the Systems Manager Run Command. The SSM Run Command runs the backup script on the instance, which uploads logs to S3. Once completed, the script signals Auto Scaling via the complete-lifecycle-action CLI command with a CONTINUE result. Finally, Auto Scaling moves the instance to Terminating:Proceed and terminates it.
The correct order follows the chronological flow of an Auto Scaling lifecycle hook from the initial scale-in determination, pausing in Terminating:Wait, triggering remediation via EventBridge, executing SSM Run Command to copy logs, signaling completion using the AWS CLI, and finally terminating the instance in Terminating:Proceed.
Step-by-Step Solution
Key Concept
Auto Scaling Lifecycle Hooks and AWS Integration