Question 8
Domain 2: Security Logging and MonitoringA company is running an application on Amazon EC2 instances in an Auto Scaling group. The application stores logs locally. A security engineer noticed that logs were lost after a scale-in event. The security engineer needs to recommend a solution to ensure the durability and availability of log data All logs must be kept for a minimum of 1 year for auditing purposes. What should the security engineer recommend?
Correct answer: C
Explanation
Amazon CloudWatch Logs provides durable, centralized log storage, so logs are not lost when an EC2 instance is terminated during a scale-in event. The CloudWatch agent can be baked into the AMI and configured to send logs off the instance, meeting the requirement that logs be kept for "a minimum of 1 year" for auditing.
Why each option is right or wrong
A. Within the Auto Scaling lifecycle, add a hook to create and attach an Amazon Elastic Block Store (Amazon EBS) log volume each time an EC2 instance is created. When the instance is terminated, the EBS volume can be reattached to another instance for log review.
EBS is block storage tied to instance workflows, not a centralized long-term logging solution.
B. Create an Amazon Elastic File System (Amazon EFS) file system and add a command in the user data section of the Auto Scaling launch template to mount the EFS file system during EC2 instance creation Configure a process on the instance to copy the logs once a day from an instance Amazon Elastic Block Store (Amazon EBS) volume to a directory in the EFS file system.
Copying logs only once daily risks losing recent logs if an instance terminates first.
C. Build the Amazon CloudWatch agent into the AMI used in the Auto Scaling group. Configure the CloudWatch agent to send the logs to Amazon CloudWatch Logs for review.
Amazon CloudWatch Logs is the durable destination here because the logs are no longer tied to the lifecycle of the EC2 instance; once shipped off-instance, they are retained independently of a scale-in termination. Under the Amazon CloudWatch Logs retention policy, log groups can be configured to retain data for a specific period, including 1 year (365 days), which satisfies the audit requirement, and the CloudWatch agent can be installed in the AMI so every replacement instance automatically forwards logs without manual reconfiguration.
D. Within the Auto Scaling lifecycle, add a lifecycle hook at the terminating state transition and alert the engineering team by using a lifecycle notification to Amazon Simple Notification Service (Amazon SNS). Configure the hook to remain in the Terminating. Wait state for 1 hour to allow manual review of the security logs prior to instance termination.
Manual review during termination delays scale-in but does not provide durable centralized log retention.