Question

Difficulty: HardImproving Operational Excellence via Monitoring and Logging

An enterprise runs a critical banking application on Amazon EC2 instances across multiple AWS accounts within an organization in AWS Organizations. The application outputs transactional logs to `/var/log/app/transaction.log`, which is rotated hourly to `/var/log/app/transaction.log.YYYY-MM-DD-HH` and compressed. The security team requires centralizing these logs into a single Amazon S3 bucket in a dedicated logging account. A Solutions Architect deployed the unified Amazon CloudWatch agent on the EC2 instances to stream these logs to Amazon CloudWatch Logs, but notices that logs are regularly lost immediately after the hourly rotation occurs. Which of the following solutions resolves this issue and achieves centralized collection securely?

  1. Configure the CloudWatch agent configuration file log path to use a wildcard pattern `/var/log/app/transaction.log*` to match rotated files. Create an Amazon Kinesis Data Firehose delivery stream in each application account to send logs to the centralized S3 bucket, and update the S3 bucket policy in the logging account to permit `firehose.amazonaws.com` with the organization ID condition.Answer
  2. B
    Configure the CloudWatch agent configuration file log path specifically to `/var/log/app/transaction.log`. Create an Amazon Kinesis Data Firehose delivery stream in each application account to send logs to the centralized S3 bucket, and update the S3 bucket policy in the logging account to permit `firehose.amazonaws.com` with the organization ID condition.
  3. C
    Configure the CloudWatch agent configuration file log path to use a wildcard pattern `/var/log/app/transaction.log*` to match rotated files. Create an Amazon Kinesis Data Firehose delivery stream in each application account to send logs to the centralized S3 bucket, and update the S3 bucket policy in the logging account to allow universal write access using a wildcard principal.
  4. D
    Configure the CloudWatch agent configuration file log path specifically to `/var/log/app/transaction.log`. Create a cross-account IAM role in each application account that grants the CloudWatch agent direct permissions to write to the centralized S3 bucket in the logging account.

Answer

Configure the CloudWatch agent configuration file log path to use a wildcard pattern to match rotated files, use Kinesis Data Firehose to stream to the centralized S3 bucket, and restrict the S3 bucket policy to the organization ID.
The correct option addresses the agent limitation by replacing the static log path with a wildcard pattern, allowing the agent to continuously monitor rotated files. It then leverages Kinesis Data Firehose to securely stream logs across accounts into a centralized S3 bucket, utilizing the Organization ID condition in the bucket policy to restrict access to trusted internal accounts.

Step-by-Step Solution

1
Address the log rotation delivery issue in the agent configuration.
Change the log path in the agent configuration JSON to a wildcard pattern such as `/var/log/app/transaction.log*`.
This allows the CloudWatch agent to automatically discover and publish logs from rotated file names as they are created.
2
Design the cross-account log ingestion mechanism.
Stream the CloudWatch logs to Amazon Kinesis Data Firehose in each account, directed to the centralized S3 bucket.
Kinesis Data Firehose buffers and aggregates data efficiently before writing it to S3, facilitating central ingestion.
3
Configure the security boundaries for the central S3 bucket.
Add a bucket policy to the centralized S3 bucket that permits access from the Firehose service principal, restricted by the `aws:PrincipalOrgID` condition.
This ensures only accounts within the organization can deliver logs to the bucket, maintaining strict isolation.

Key Concept

Configuring the CloudWatch agent log path with wildcards to handle log rotation, combined with secure cross-account centralization via S3 bucket policies constrained by Organization ID.
Rate this question