# Auditing with CloudTrail and AWS Config

> Record every API call with CloudTrail, track configuration history and compliance with AWS Config, and investigate who changed what. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/cloud-engineer/cloudtrail-config
Last updated: 2026-11-28

Record every API call with CloudTrail, track configuration history and compliance with AWS Config, and investigate who changed what.

Intermediate · about 3 hours · difficulty 2/5

Learn first: [CloudWatch Metrics, Logs and Alarms](https://www.internhack.in/roadmaps/tracks/cloud-engineer/cloudwatch), [Multi-Account Strategy with AWS Organizations](https://www.internhack.in/roadmaps/tracks/cloud-engineer/organizations-scps)

When a security group is opened to the world at 2 am, you need to know who did it, from where and when. That is what auditing services are for.

### AWS CloudTrail

- Records **management events** (API calls like RunInstances, PutBucketPolicy, CreateUser) in every account, including console clicks.
- **Event history** shows the last 90 days for free.
- Create an **organization trail** that delivers logs from all accounts and regions to a central, locked-down S3 bucket in a log archive account.
- **Data events** (S3 object reads, Lambda invokes) cost extra; enable them selectively for sensitive buckets.
- **CloudTrail Lake** or Athena lets you query trails with SQL.

### AWS Config

- Records the **configuration history** of resources: what a security group looked like last Tuesday.
- **Config rules** (managed or custom) check compliance continuously: S3 buckets must block public access, EBS volumes must be encrypted, root must have MFA.
- **Conformance packs** bundle rules for frameworks like CIS benchmarks.
- **Remediation** can fix non-compliant resources automatically through SSM documents.

Azure Activity Log with Azure Policy, and Google Cloud Audit Logs with Security Command Center cover similar ground.

### Pitfalls

- No multi-region trail, so activity in unused regions (often where attackers launch miners) goes unseen.
- Trail logs stored in a bucket that the same admins can delete.
- Turning on every Config rule in every region and paying for evaluations nobody reads.

You are ready to move on when you can find, in CloudTrail, who modified a specific security group and show its previous configuration in Config.

## Key concepts

- **Management vs data events**
- **Event history**
- **Organization trails**
- **Log file integrity validation**
- **AWS Config recorder**
- **Config rules and conformance packs**
- **Querying trails with Athena or CloudTrail Lake**

## Mini project

Create a multi-region trail delivering to an S3 bucket, open and close port 22 on a security group, then find both events in CloudTrail and write the who, what, when and source IP. Enable one Config rule (s3-bucket-public-read-prohibited) for an hour. Delete the Config recorder afterwards because evaluations are billed.

## Check yourself

Which service answers 'who deleted this bucket?', and which answers 'what did this security group look like last week?'

## Free resources

- [AWS CloudTrail documentation](https://docs.aws.amazon.com/cloudtrail/) (AWS)
- [AWS Config documentation](https://docs.aws.amazon.com/config/) (AWS)

Previous: [Distributed Tracing with X-Ray and OpenTelemetry](https://www.internhack.in/roadmaps/tracks/cloud-engineer/xray-tracing) · Next: [Encryption with AWS KMS](https://www.internhack.in/roadmaps/tracks/cloud-engineer/kms-encryption)

## More in Observability and Auditing

- [CloudWatch Metrics, Logs and Alarms](https://www.internhack.in/roadmaps/tracks/cloud-engineer/cloudwatch)
- [Distributed Tracing with X-Ray and OpenTelemetry](https://www.internhack.in/roadmaps/tracks/cloud-engineer/xray-tracing)
- [Auditing with CloudTrail and AWS Config](https://www.internhack.in/roadmaps/tracks/cloud-engineer/cloudtrail-config)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cloud Engineer (AWS) Roadmap](https://www.internhack.in/roadmaps/tracks/cloud-engineer)
