Welcome to Day 14 of the 30 Days AWS Security Challenge, and the start of week three. We've spent two weeks on prevention, identity, data, and network. Starting today, we shift into monitoring and detection, because prevention alone is never perfect, and you need visibility into what is actually happening in your account.
Why You Need a Record of Everything
If something goes wrong in your AWS account, whether it is a misconfiguration, a compromised credential, or just a mistake someone made, your first question is always the same: what happened, and who did it? Without a record of account activity, you are left guessing. That record is exactly what CloudTrail provides.
What CloudTrail Actually Records
CloudTrail logs API calls made across your AWS account. Nearly everything you do in AWS, whether through the console, the CLI, or an SDK, eventually turns into an API call, and CloudTrail captures the details of that call: who made it, when, from where, what action was taken, and what resource it affected.
This means CloudTrail can answer questions like:
- Who deleted this S3 bucket, and when?
- Which IAM user or role created this EC2 instance?
- Was this security group rule changed by a person or an automated process?
- Did anyone log in as the root user this month?
Management Events vs Data Events
CloudTrail records two broad categories of events, and knowing the difference matters:
- Management events cover control plane operations, things like creating a user, changing a security group, or launching an instance. These are logged by default and cover most of what you need for account level auditing.
- Data events cover operations on the data inside resources, like reading or writing an individual S3 object, or invoking a Lambda function. These are far higher volume and are not enabled by default, since logging every single object read can generate a huge amount of data.
For most accounts, management events give you the bulk of the security value. Data events are worth enabling selectively, for example on S3 buckets holding especially sensitive data, where you want to know exactly which objects were accessed.
Is CloudTrail Already On?
Every AWS account actually has CloudTrail enabled by default, showing the last 90 days of management events under CloudTrail > Event history. The problem is that this default view is limited: it only covers 90 days, it is not stored anywhere durable, and it does not cover every AWS Region unless you set that up deliberately.
Setting Up a Proper Trail
To get real value out of CloudTrail, you want to create what's called a trail, which stores events durably in an S3 bucket and can also feed into services like CloudWatch Logs for alerting.
To set this up, go to CloudTrail > Trails > Create trail, give it a name, and choose an S3 bucket to store the logs (CloudTrail can create one for you). Enable it for all regions, so activity anywhere in your account gets captured, not just in the region you happen to be working in. From there, you can optionally send events to CloudWatch Logs as well, which makes it possible to set up automated alerts based on specific activity.
A Practical Example: Alerting on Root Login
Remember our root account discussion from Day 6? CloudTrail is what makes root activity alerting actually possible. Once your trail is feeding into CloudWatch Logs, you can create a metric filter that looks for root login events, paired with a CloudWatch Alarm that notifies you through SNS the moment it happens. This turns "root logins should be rare" from a policy on paper into something you actively get notified about.
Protecting Your Trail Itself
One detail worth knowing early: if an attacker gains enough access to your account, one of the first things they might try is disabling CloudTrail to cover their tracks. Protect against this by enabling log file validation on your trail, which detects tampering, and consider using an SCP (from Day 7) to prevent CloudTrail from being disabled at all across your organization.
Key Takeaways
- CloudTrail logs API activity across your account, answering who did what and when
- A basic 90 day event history exists by default, but a proper trail with S3 storage gives you durable, long term records
- Management events cover most security needs, data events are higher volume and worth enabling selectively
- Enable your trail across all regions, not just the one you use most
- Protect the trail itself with log file validation and consider an SCP to prevent it from being disabled
Tomorrow we look at a service that actively watches this kind of activity for you and flags suspicious behavior automatically: Amazon GuardDuty.
Loading article