Sub topic 1
What CloudTrail records and why it matters for auditing
Prerequisites
This chapter assumes you know the following:
- Basic AWS account and IAM concepts: users, roles, and policies.
- What an Amazon S3 bucket is.
- How to read JSON.
- How to run simple AWS CLI commands.
You do not need to have used CloudTrail before.
The core idea
AWS CloudTrail records API activity in your AWS account. Almost everything you do in AWS is an API call. Clicking a button in the console, running aws s3 mb in the CLI, and calling an SDK from your code all end up as requests to a service API. CloudTrail writes one event for each of these requests.
Each event answers the basic audit questions:
- Who made the call: a user, a role, or an AWS service acting on your behalf.
- What they did: the service and the API action, such as
StopLoggingon CloudTrail. - When it happened: a UTC timestamp.
- Where it came from: the source IP address and the client, such as the console or the CLI.
- On what it acted: the request parameters and the resources involved.
- Outcome: whether the call succeeded or failed.
An audit is an after-the-fact check of what happened and whether it was allowed. CloudTrail supplies the evidence for that check.
What it records and what it does not
CloudTrail is often assumed to record more than it does. The table below separates what it covers from what needs another tool.
| Question | Covered by CloudTrail? | Where to look otherwise |
|---|---|---|
| Who created or deleted an EC2 instance? | Yes | None needed |
| Who changed a security group? | Yes | None needed |
| Who failed to call an API because of missing permissions? | Yes, failed calls are recorded with an error code | None needed |
| Who read or wrote a specific S3 object? | Only if data events are enabled | Enable data events on a trail |
| What commands ran inside an EC2 instance? | No | OS and application logs |
| What network traffic reached an instance? | No | VPC Flow Logs |
| What did a resource's configuration look like last month? | No, it records the change calls only | AWS Config |
| How busy was a resource? | No | Amazon CloudWatch metrics |
CloudTrail records the control plane by default. The control plane is the set of calls that create, change, or delete resources. These are called management events. Reads and writes of the data stored in resources, called data events, are off by default because they are high volume. Later chapters cover event categories in detail.
Why this matters for auditing
- Accountability. Every change can be traced to an identity.
- Security investigation. After a suspected compromise, you can see which credentials were used, from which IP address, and what they touched.
- Compliance. Many frameworks require a tamper-evident record of administrative activity.
- Troubleshooting. A resource that changed unexpectedly usually has a matching event.
Two ways to access the records
CloudTrail is enabled on every account, so you have some records without setting anything up. These are shown in Event history, which has three limits:
- It holds the last 90 days only.
- It shows management events only.
- It is searched one Region at a time.
A trail is a configuration you create to keep records beyond those limits. It delivers events to an S3 bucket, where you control retention and can add data events. If you need records older than 90 days, you need a trail. The 90-day window is a common source of "the evidence is gone" surprises during an investigation.
Common mistakes
- Searching in the wrong Region. Event history shows the Region you have selected. Events from global services such as IAM appear in
us-east-1. - Assuming "no event" means "no activity". The activity may be a data event, or it may have happened inside an instance where CloudTrail cannot see it.
- Forgetting that failed attempts are recorded too. They are useful, because repeated
AccessDeniederrors can reveal someone probing for permissions.
Exercise
A teammate says an object in an S3 bucket was deleted last week and asks you to find who did it using Event history, which shows nothing. Name two reasons CloudTrail might not show it.
Show answer
First, deleting an S3 object is a data event, and data events are not recorded unless you enabled them on a trail. Event history shows management events only. Second, if the deletion happened more than 90 days ago, it is outside the Event history window. A trail that already logged data events for that bucket would be the only source of the record.