Sub topic 10
Centralized CloudTrail and AWS Config records
This chapter assumes you have launched a landing zone, as covered in the earlier chapters. It also assumes you know what the Log Archive and Audit accounts are, and that you are comfortable with S3 buckets, IAM roles, and the AWS CLI. Here you will see which CloudTrail and AWS Config resources Control Tower creates, where their records end up, and how to read them.
Why centralize the records
A multi-account environment produces activity records in every account and Region. If each account kept its own, an engineer investigating an incident would have to sign in to many accounts. Anyone with administrator access in a workload account could also delete the evidence of their own actions.
Control Tower avoids both problems by sending records to one place that workload owners cannot reach. It uses two services:
- AWS CloudTrail records API calls and console actions. It answers the question "who did what, and when?"
- AWS Config records the configuration of resources over time and evaluates them against rules. It answers the question "what does this resource look like now, and was it compliant?"
What Control Tower deploys
Control Tower sets up both services during launch. It repeats the setup for each account you create or enroll.
| Resource | Where it lives | Purpose |
|---|---|---|
| Organization trail | Created from the management account, covers all enrolled accounts | Records management events for every enrolled account in every governed Region |
| CloudTrail S3 bucket | Log Archive account | Stores the trail's log files |
| CloudWatch Logs group | Management account | Holds a copy of the trail events for searching and alarms |
| Config recorder and delivery channel | Every enrolled account, in every governed Region | Records configuration changes and delivers them to S3 |
| Config S3 bucket | Log Archive account | Stores configuration history and snapshots from all accounts |
| Config aggregator | Audit account | Collects compliance and inventory data from all accounts into one view |
| SNS topics | Audit account | Carry notifications about configuration changes and compliance events |
Resource names start with aws-controltower-. The recorder is named aws-controltower-BaselineConfigRecorder. The aggregator is named aws-controltower-GuardrailsComplianceAggregator.
The Log Archive account stores the records. The Audit account is where people read and query them.
CloudTrail in the landing zone
The trail is an organization trail. You create it once, and it applies to every enrolled account. Member accounts see the trail but cannot change or delete it. Local administrators cannot turn off logging in their own account.
The trail captures management events, which are control-plane actions such as CreateBucket, RunInstances, and PutRolePolicy. It does not capture data events by default. Data events include S3 object reads and writes and Lambda invocations. They are high volume and cost extra, so you must add them yourself if you need them.
Log files are written to the Log Archive bucket under a prefix that includes the organization ID and the account ID. To find one account's activity, go to the account's prefix:
aws s3 ls s3://<cloudtrail-bucket>/<org-id>/AWSLogs/<org-id>/<account-id>/CloudTrail/ \
--recursive --human-readable | headReplace the placeholders with values from the Log Archive account. Run the command with credentials for that account. The exact key layout can vary with the landing zone version, so list the bucket top level first if the path does not match.
You can also confirm the trail from the management account:
aws cloudtrail describe-trails --region us-east-1
aws cloudtrail get-trail-status \
--name <trail-name-or-arn> \
--region us-east-1Check that IsOrganizationTrail is true and that IsLogging is true in the status output.
AWS Config in the landing zone
Control Tower enables a Config recorder in every enrolled account, in each governed Region. The recorder watches resource configurations and writes a configuration item each time a resource changes. The delivery channel sends these items, plus periodic snapshots, to the Config bucket in the Log Archive account.
Detective controls are implemented as AWS Config rules. When you enable a detective control on an OU, Control Tower deploys the matching Config rule into each account in that OU. Compliance results then appear in each account and are aggregated in the Audit account.
Check that the recorder works in a member account:
aws configservice describe-configuration-recorders --region us-east-1
aws configservice describe-configuration-recorder-status --region us-east-1Each governed Region should show a recorder with recording: true. If a Region is not governed, Control Tower does not set up a recorder there, so an empty result in an ungoverned Region is expected.
Reading compliance from the Audit account
The aggregator in the Audit account gives you a cross-account view without signing in to each account. From the Audit account, list compliance by rule:
aws configservice describe-aggregate-compliance-by-config-rules \
--configuration-aggregator-name aws-controltower-GuardrailsComplianceAggregator \
--filters ComplianceType=NON_COMPLIANT \
--region us-east-1The output lists each rule and account with a non-compliant result. You can then drill into one result with get-aggregate-compliance-details-by-config-rule, which takes the aggregator name, the rule name, the account ID, and the Region.
The aggregator reports on the rules and resources it can see, so its view depends on the recorder running in each account. A Region where the recorder is stopped produces gaps, not failures.
Retention and encryption
During launch you choose how long Control Tower keeps logs. The setup page offers one retention period for the main log buckets and another for the S3 access logs of those buckets. Control Tower applies these as S3 lifecycle rules.
You can also choose a KMS key to encrypt the logs. Without your own key, the buckets use S3-managed encryption. If you use your own key, the key policy must allow the CloudTrail and Config service principals, and the policy must stay valid as you add accounts. A key policy that blocks those services can cause a landing zone update or an account enrollment to fail.
| Setting | Chosen | Can you change it later? |
|---|---|---|
| Log retention periods | At launch | Yes, by updating the landing zone settings |
| KMS key | At launch | Yes, by updating the landing zone settings, but the key policy must be correct first |
| Log Archive and Audit accounts | At launch | Not without decommissioning the landing zone |
Common errors and gotchas
- Editing Control Tower resources directly. If you stop a recorder, delete a delivery channel, or change the bucket policy, Control Tower reports drift. Repair it from the Control Tower console or by updating the landing zone. Do not fix it by hand in the Config or CloudTrail consoles.
- Expecting data events. The trail records management events only. Add S3 or Lambda data event logging separately, and budget for the volume.
- Looking in the wrong account. The raw files are in the Log Archive account, and the aggregated compliance view is in the Audit account. Neither is in the management account.
- Giving broad access to the Log Archive account. Read access to its buckets exposes the activity of every account. Grant read-only roles to a small security group through IAM Identity Center permission sets.
- Forgetting Regions. Records exist only for governed Regions. Activity in an ungoverned Region is not recorded by the Control Tower baseline, though preventive controls can deny that activity.
- Config cost. Config charges per configuration item recorded. A governed Region with many short-lived resources produces many items. Review cost before adding Regions.
Exercises
Exercise
You need the raw CloudTrail files for one workload account from last Tuesday. Which account holds them, and which account would you use to see which accounts currently fail a detective control?
Show answer
The raw CloudTrail files are in the S3 bucket in the Log Archive account, under the prefix for that workload account's ID. The cross-account compliance view comes from the Config aggregator in the Audit account.
Exercise
A developer with administrator access in a workload account stops the AWS Config recorder in that account. What does Control Tower report, and how should you fix it?
Show answer
Control Tower reports drift for that account, because the baseline resources no longer match the expected state. Fix it by repairing the account or updating the landing zone from Control Tower, not by manually recreating the recorder.
Exercise
Write the CLI command, run in the Audit account, that lists only non-compliant results across all accounts.
Show answer
aws configservice describe-aggregate-compliance-by-config-rules --configuration-aggregator-name aws-controltower-GuardrailsComplianceAggregator --filters ComplianceType=NON_COMPLIANT --region us-east-1