
Answer-first summary for fast verification
Answer: Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
The correct answer is D. Using Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state allows you to pause the instance termination process, giving you time to collect logs. Creating an Amazon EventBridge rule for the EC2 Instance-terminate Lifecycle Action is the recommended approach to handle such events seamlessly. This rule triggers an AWS Lambda function which can invoke an SSM Run Command script to collect logs and push them to Amazon S3, ensuring you have the necessary log data before the instance is fully terminated.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
No comments yet.
A developer is managing a fleet of 50 Amazon EC2 Linux servers integrated with an Amazon EC2 Auto Scaling group and Elastic Load Balancing. Occasionally, servers are terminated due to failed ELB HTTP health checks, preventing timely access to application logs for root cause analysis. What strategy should the developer implement to automate the collection of logs before server termination?
A
Use Auto Scaling lifecycle hooks to put instances in a Pending:Wait state. Create an Amazon CloudWatch alarm for EC2 Instance Terminate Successful and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
B
Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an AWS Config rule for EC2 Instance-terminate Lifecycle Action and trigger a step function that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
C
Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon CloudWatch subscription filter for EC2 Instance Terminate Successful and trigger a CloudWatch agent that invokes a script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.
D
Use Auto Scaling lifecycle hooks to put instances in a Terminating:Wait state. Create an Amazon EventBridge rule for EC2 Instance-terminate Lifecycle Action and trigger an AWS Lambda function that invokes an SSM Run Command script to collect logs, push them to Amazon S3, and complete the lifecycle action once logs are collected.