After deploying a new feature, some Auto Scaling group EC2 instances became unhealthy and were terminated before an administrator could investigate. The admin wants an AWS Lambda function to run whenever an instance is being replaced so they can gather diagnostics. How should the admin ensure the Lambda function is invoked during instance replacement?
Choose an answer
Tap an option to check your answer.
Correct answer: Add an Auto Scaling lifecycle hook that sends the instance termination lifecycle event to invoke the Lambda function via Amazon EventBridge (CloudWatch Events)..
Why this is the answer
The correct solution involves using an Auto Scaling lifecycle hook. A lifecycle hook allows you to pause an instance as it launches or terminates, giving you time to perform custom actions. By adding a lifecycle hook for instance termination, you can configure it to send an event to Amazon EventBridge (formerly CloudWatch Events). EventBridge can then be configured with a rule to invoke a Lambda function when it receives this specific event, allowing the administrator to gather diagnostics before the instance is fully terminated. Enabling instance scale-in protection would prevent instances from being terminated, which is not the goal here; the administrator wants to react during termination. Route 53 is a DNS service and is not used for triggering Lambda functions based on Auto Scaling events.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed