Sub topic 2
Creating a trail and choosing event selectors
Assume you understand IAM users, roles, S3 buckets, JSON, and basic AWS CLI commands. A CloudTrail trail continuously delivers selected account activity to an S3 bucket for retention and investigation.
Create a trail
Create a multi-Region trail when the account uses resources in more than one Region. The destination bucket must already exist, and its bucket policy must allow CloudTrail to write log files.
aws cloudtrail create-trail \
--name org-audit-trail \
--s3-bucket-name my-cloudtrail-logs-bucket \
--is-multi-region-trail \
--enable-log-file-validation
aws cloudtrail start-logging --name org-audit-trailA trail records management events by default when configured for them. These events describe control-plane actions such as creating an IAM role or changing a security group. Data events describe operations inside a resource, such as reading an S3 object. Data events can produce many records, so select them deliberately.
aws cloudtrail put-event-selectors \
--trail-name org-audit-trail \
--advanced-event-selectors '[
{
"Name": "Management events",
"FieldSelectors": [
{"Field": "eventCategory", "Equals": ["Management"]}
]
},
{
"Name": "S3 objects in one bucket",
"FieldSelectors": [
{"Field": "eventCategory", "Equals": ["Data"]},
{"Field": "resources.type", "Equals": ["AWS::S3::Object"]},
{"Field": "resources.ARN",
"StartsWith": ["arn:aws:s3:::my-sensitive-bucket/"]}
]
}
]'S3 delivery and organization
CloudTrail stores compressed log files under a prefix containing the account ID, Region, and date. A typical path resembles:
AWSLogs/123456789012/CloudTrail/us-east-1/2026/11/20/...
The bucket policy grants the CloudTrail service permission to write there. Restrict access to security administrators and separate log storage from ordinary application data.
A multi-Region trail records supported management events from all Regions and delivers them to one destination. An organization trail, created by the management account or delegated administrator, can apply auditing across member accounts. Confirm the organization’s bucket policy and access model before enabling it.
Validate log integrity
Log file validation uses digest files to detect modification, deletion, or missing files after delivery.
aws cloudtrail validate-logs \
--trail-arn arn:aws:cloudtrail:us-east-1:123456789012:trail/org-audit-trail \
--start-time 2026-11-01T00:00:00Z \
--end-time 2026-11-20T00:00:00ZExercise
Why might a trail fail to show an S3 object read?
Show answer
S3 object reads are data events. The trail must explicitly select that bucket and event category.