AWS Certified Solutions Architect – Professional (SAP-C02) — Question 521

A company is running an application on several Amazon EC2 instances in an Auto Scaling group behind an Application Load Balancer. The load on the application varies throughout the day, and EC2 instances are scaled in and out on a regular basis. Log files from the EC2 instances are copied to a central Amazon S3 bucket every 15 minutes. The security team discovers that log files are missing from some of the terminated EC2 instances.
Which set of actions will ensure that log files are copied to the central S3 bucket from the terminated EC2 instances?

Answer options

Correct answer: B

Explanation

An Auto Scaling lifecycle hook allows you to pause the termination of an instance, putting it into a Terminating:Wait state so that custom tasks like log exporting can complete. By combining this hook with an Amazon EventBridge rule, an AWS Lambda function can be triggered to execute an AWS Systems Manager Run Command (SendCommand) to run the log-copying script on the instance. Once the script finishes, sending a CONTINUE signal to the Auto Scaling group allows the termination process to proceed successfully, whereas sending ABANDON or attempting to run scripts post-termination would fail.