Which solution achieves these goals MOST efficiently?
Use a scheduled AWS Lambda function and run a script remotely on all EC2 instances to send data to the audit system.
Use EC2 Auto Scaling lifecycle hooks to run a custom script to send data to the audit system when instances are launched and terminated.
Use an EC2 Auto Scaling launch configuration to run a custom script through user data to send data to the audit system when instances are launched and terminated.
Run a custom script on the instance operating system to send data to the audit system. Configure the script to be executed by the EC2 Auto Scaling group when the instance starts and is terminated.
Explanations:
While using a scheduled AWS Lambda function could gather data from instances, it doesn’t trigger the report sending immediately upon instance launch or termination, making it less efficient.
EC2 Auto Scaling lifecycle hooks allow for executing a custom script during instance launch and termination, ensuring that reports are sent immediately and efficiently as part of the scaling process.
Using a launch configuration with user data only triggers the script on instance launch, not termination, failing to meet the requirement for both events.
Running a script on the instance operating system relies on the instance being active, and may not efficiently handle terminations as it lacks integration with lifecycle hooks for immediate reporting.