An enterprise operates a microservices-based application running on Amazon EC2 instances across multiple member accounts in an AWS Organization. The application logs are stored locally on the instances in `/var/log/app/application.log` and undergo hourly rotation, renaming the files with a timestamp suffix (for example, `/var/log/app/application.log.2026-07-16-11`). A Solutions Architect must design a centralized logging solution to stream these logs in near real-time to an Amazon S3 bucket in a central security account. The solution must ensure that log collection is continuous and unaffected by file rotation, and it must follow the principle of least privilege, avoiding cross-account IAM role assumptions from EC2 instances where resource-based policies can be used instead. Which two actions should the Solutions Architect take to implement this solution?
- Configure the CloudWatch agent on the EC2 instances using a wildcard path configuration, such as `/var/log/app/application.log*`, to monitor the log directory, and stream the logs to a local log group in each member account's Amazon CloudWatch Logs.Cevap
- In the central security account, update the S3 bucket policy to allow `s3:PutObject` and `s3:PutObjectAcl` permissions, specifying the Kinesis Data Firehose delivery stream IAM roles from each member account as the principals. In each member account, create a Kinesis Data Firehose delivery stream targeting the central S3 bucket, and set up a CloudWatch Logs subscription filter to forward the logs to the local delivery stream.Cevap
- CConfigure the CloudWatch agent on the EC2 instances with a static file path configuration pointing directly to `/var/log/app/application.log`, relying on the agent's default file-tracking behavior to automatically track rotated log descriptors.
- DConfigure the CloudWatch agent on the EC2 instances to stream logs directly to an Amazon Kinesis Data Firehose delivery stream in the central account. Update the destination S3 bucket policy to grant write access using a wildcard principal with a condition limiting access to the AWS Organization ID using the `aws:PrincipalOrgID` key.
- ECreate a cross-account IAM role in the central security account that has permissions to write to CloudWatch Logs. Configure the CloudWatch agent on the EC2 instances in each member account to assume this cross-account role and write the log streams directly to a centralized log group.