A company deployed a new auditing system that centralizes OS versions, patching, and installed software for Amazon EC2 instances. Ensure that all instances provisioned through EC2 Auto Scaling groups send reports to the auditing system as soon as they are launched and when they are terminated. Which solution achieves this most efficiently?
Choose an answer
Tap an option to check your answer.
Correct answer: Use EC2 Auto Scaling lifecycle hooks to run a custom script to send data to the audit system when instances are launched and terminated..
Why this is the answer
EC2 Auto Scaling lifecycle hooks allow you to pause instances as they launch or terminate, giving you time to perform custom actions. By configuring a lifecycle hook for both EC2INSTANCELAUNCHING and EC2INSTANCETERMINATING states, you can invoke a custom script or a Lambda function to send reports to the auditing system at the precise moments an instance is provisioned or decommissioned. This ensures all instances report their status without manual intervention. Using a scheduled Lambda function to run a script remotely is inefficient and might miss instances that launch and terminate between schedules. An EC2 Auto Scaling launch configuration with user data only executes on launch and doesn't handle termination events. Running a custom script directly on the OS without lifecycle hooks doesn't provide a reliable mechanism to trigger actions specifically at termination or to pause the termination process until the report is sent.
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