Detection · Topic 5 of 7

CloudTrail Logging Design

Design AWS CloudTrail logging with organization trails, event types, log file validation, KMS encryption, protected S3 buckets and CloudTrail Lake queries.

  • 6 min
  • Includes a diagram
In a nutshell
  • Event history covers 90 days of management events only. A trail is required for longer retention and for data events.
  • Use a multi Region organization trail delivering to a bucket in a central log archive account.
  • Log file integrity validation produces signed digests, and validate-logs verifies them.

What it is

AWS CloudTrail records API activity in your accounts: who called which API, from where, when and with what result. It is the primary audit log on AWS and the starting point of almost every investigation.

A logging design has to answer four questions: what to record, where to keep it, how to protect it from tampering, and how to query it.

API callsconsole, CLI, SDKrecordedCloudTrailtraildeliversS3 log archivecentral accountqueriedAthena or Lakeinvestigation

How it works

Event types

Event typeWhat it recordsOn by default
Management eventsControl plane actions, such as creating a role or changing a security groupYes, in Event history
Data eventsData plane actions, such as S3 object reads and writes or Lambda invocationsNo, and they cost more
Insights eventsUnusual API call rates or error ratesNo
Network activity eventsAPI activity through VPC endpointsNo

Event history in the console shows the last 90 days of management events at no charge. To keep events longer, to log data events, or to query across accounts, create a trail or a CloudTrail Lake event data store.

Trail design

!API calls in member accounts are recorded by an organization trail (multi Region, log file validation) that delivers to an S3 log bucket with Object Lock, versioning and SSE-KMS in a central log archive account, queried with Athena; the same events can feed CloudTrail Lake or, optionally, CloudWatch Logs, and an SCP stops members removing the trail. A trail delivers log files to an S3 bucket, and optionally to CloudWatch Logs for alarms. For security, use these options.

  • Multi Region trail, so activity in unused Regions is recorded too and global service events are included.
  • Organization trail, created from the management account or a delegated administrator, which logs every member account and cannot be removed by those accounts.
  • Log file integrity validation, which writes signed digest files so you can prove that logs were not changed or deleted.
  • SSE-KMS encryption, with a customer managed key whose policy allows CloudTrail to encrypt and your analysts to decrypt.
  • A central log archive account, so an attacker who controls a workload account cannot erase the evidence.

Data events are chosen with advanced event selectors, which let you log only specific buckets or functions instead of everything. This keeps volume and cost under control.

Protecting the log bucket

The S3 bucket policy must let the CloudTrail service write, and it should scope that permission to your trail with aws:SourceArn.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AWSCloudTrailAclCheck",
      "Effect": "Allow",
      "Principal": { "Service": "cloudtrail.amazonaws.com" },
      "Action": "s3:GetBucketAcl",
      "Resource": "arn:aws:s3:::amzn-s3-demo-logs",
      "Condition": { "StringEquals": { "aws:SourceArn": "arn:aws:cloudtrail:us-east-1:111122223333:trail/org-trail" } }
    },
    {
      "Sid": "AWSCloudTrailWrite",
      "Effect": "Allow",
      "Principal": { "Service": "cloudtrail.amazonaws.com" },
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-logs/AWSLogs/111122223333/*",
      "Condition": { "StringEquals": {
        "s3:x-amz-acl": "bucket-owner-full-control",
        "aws:SourceArn": "arn:aws:cloudtrail:us-east-1:111122223333:trail/org-trail" } }
    }
  ]
}

For an organization trail the write statement also covers the organization path. Add layers of protection around the bucket.

  • Block Public Access and a deny for non secure transport.
  • S3 Versioning and S3 Object Lock in compliance mode, for write once retention.
  • A lifecycle rule that moves old logs to cheaper storage rather than deleting them early.
  • An SCP (service control policy) that stops member accounts from stopping or deleting the trail.

Verifying integrity

Run the validation command to check that delivered logs match their digests.

# AWS CLI
aws cloudtrail validate-logs \
  --trail-arn arn:aws:cloudtrail:us-east-1:111122223333:trail/org-trail \
  --start-time 2026-01-01T00:00:00Z

Validation uses SHA-256 hashing and a digital signature on the digest files, and it reports log files that are modified, deleted or missing.

Querying logs

OptionStrengthsChoose it when
Athena on the S3 logsPay per query, SQL, flexibleYou already store trails in S3 and queries are occasional
CloudTrail LakeManaged event data store, SQL, no table setup, can span accountsYou want fast ad hoc queries and long retention without building a pipeline
CloudWatch Logs InsightsFast queries on log groupsThe trail already delivers to CloudWatch Logs
Member accountsorganization traillogsLog archiveS3 with Object LockSQLAthenainvestigationMember accountsorganization traileventsCloudTrail Lakeevent data storeSQLAnalystquery

What to remember for the exam

  • Event history covers 90 days of management events only. A trail is required for longer retention and for data events.
  • Use a multi Region organization trail delivering to a bucket in a central log archive account.
  • Log file integrity validation produces signed digests, and validate-logs verifies them.
  • Data events are off by default, and advanced event selectors limit them to chosen resources.
  • The bucket policy trusts cloudtrail.amazonaws.com and should use aws:SourceArn to prevent confused deputy use.
  • Protect logs with Object Lock, versioning, SSE-KMS, restricted deletes and an SCP against trail changes.
  • Send the trail to CloudWatch Logs only when you need metric filters or Logs Insights on it.
  • CloudTrail Lake gives SQL queries without building an Athena table, with retention you configure.
Exam tip

For "prove that the log files have not been altered", choose log file integrity validation. For "prevent anyone, even administrators, from deleting logs", choose S3 Object Lock in compliance mode.

Common mistakes

Believing CloudTrail logs S3 object reads by default. Object level activity is a data event and must be switched on.

Single Region trails. An attacker uses the Region you are not watching, and the evidence is missing.

Forgetting the KMS key policy. If CloudTrail cannot use the key, log delivery fails and the trail shows a delivery error.

Keeping the logs in the account being audited. A compromised administrator can then delete the trail and the bucket together.

Watch out

A normal trail can be stopped or deleted by an administrator of that account, so use an organization trail and an SCP that denies cloudtrail:StopLogging and cloudtrail:DeleteTrail for member accounts.

Check yourself

  • How do you log every account in an organization and prevent members from removing the trail?

    Create an organization trail from the management or delegated administrator account.

  • What proves that log files were not changed after delivery?

    Log file integrity validation, which creates signed digest files that aws cloudtrail validate-logs checks.

  • Which setting records S3 object level reads and writes?

    Data events, enabled on the trail or event data store, since they are not recorded by default.

Topic 5 of 7 in Detection

Test yourself on Detection

The full AWS SCS-C03 question bank has 858 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by AWS. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.