Courseiva
DOP-C02Chapter 18 of 18Objective 6.3

Auditing and Governance with AWS CloudTrail and Config

DOP-C02 objective 6.3 focuses specifically on how to enable auditing and governance using CloudTrail, Config, and GuardDuty. These tools solve a critical problem: how can you possibly know what happened inside your AWS account after something goes wrong. For beginners studying for the DOP-C02, understanding these three services is like learning the security cameras, alarm system, and guard patrol for your entire cloud infrastructure.

12 min read
Intermediate
Updated Jul 23, 2026
Reviewed by Johnson Ajibi· Senior Network & Security Engineer · MSc IT Security

A simple way to picture Auditing and Governance with AWS CloudTrail and Config

The House Party Host Analogy

When you host a big house party, the first thing you do is decide on a guest list and set some ground rules. This leads to the need to know exactly what happens during the party. CloudTrail is like having a security camera that records every single action, like who opened the fridge, who went into the garden, and who turned on the music. It gives you a complete, unchangeable video log of the entire event. Config is like a checklist you run before and during the party. It checks that the doors are locked, the fire extinguisher is in place, and the noise is within limits. If someone moves the fire extinguisher, Config immediately notices and sends you an alert. It doesn't stop the person, but it tells you the rule has been broken.

Together, these two tools give you complete oversight. You have the video record (CloudTrail) of every action and the constant compliance checks (Config) against your party rules. If something goes wrong, you can rewind the video to see exactly who did what and when. If a rule is broken, you get a notification so you can fix it. This is how AWS auditing and governance works — you watch what happened and ensure your setup stays within the rules you set, all without needing to be in the room yourself.

How It Actually Works

Let's start with the core problem. You have an AWS account. People and services inside that account are constantly creating, modifying, and deleting resources like virtual servers (EC2 instances), databases, and storage buckets. As a DevOps engineer, you are responsible for the security and compliance of this environment. But you cannot watch every action live. You need a system that records everything and checks everything automatically. This is where CloudTrail and Config come in.

CloudTrail is AWS's service for auditing. Think of it as a security camera that records every single API call made to your AWS account. An API call is just a command issued to AWS to do something — like 'launch an EC2 instance', 'create an S3 bucket', or 'change a security group rule'. CloudTrail captures who made the call, when it was made, what the call was, where it came from (the IP address), and what the result was. This record is stored as a 'trail', which is a log file that can be saved to an S3 bucket (a storage container) for long-term storage and analysis.

Every action is recorded: actions via the AWS Management Console (the web interface), via the AWS CLI (command line interface), via SDKs (software development kits), and via other AWS services acting on your behalf. This means you have an immutable, tamper-proof record of everything. If a developer accidentally deletes a production database, CloudTrail will show exactly who issued the delete command and when. It cannot prevent the action, but it provides the evidence for incident response.

CloudTrail has two main modes: management events and data events. Management events are actions on resources like launching an EC2 instance or creating a VPC. These are recorded by default and are free. Data events are actions inside those resources, like reading an object from an S3 bucket or invoking a Lambda function. These are more costly and are not enabled by default. For the DOP-C02 exam, you must know the difference: management events are always on, data events must be specifically enabled. Multi-region trails are another key concept. A multi-region trail records events from all AWS regions into a single S3 bucket, giving you a single pane of glass for your entire global infrastructure.

AWS Config is a different service with a different purpose. While CloudTrail records actions (the 'who did what'), Config records the state of your resources (the 'what's the current configuration'). Config is a continuous compliance monitoring and configuration tracking service. It takes a snapshot of your resources at regular intervals and compares them to the rules you define. These rules are called 'Config rules'. You can use managed rules provided by AWS (like 'ec2-instances-against-security-group' or 's3-bucket-public-read-prohibited') or create your own custom rules using AWS Lambda (a serverless function).

For example, you can create a Config rule that says 'all S3 buckets must be private'. Config will then evaluate all your S3 buckets every time they change, or at a specified frequency, and report each bucket as 'compliant' or 'non-compliant'. If someone later makes an S3 bucket public, Config will detect that change and flag it as non-compliant. Config can also trigger automatic remediation actions, like making the bucket private again or sending a notification to a security team. Config keeps a historical record of your resource configurations. You can see what an EC2's security group looked like last week compared to today. This is extremely useful for troubleshooting and compliance auditing.

The relationship between CloudTrail and Config is complementary. When Config detects a non-compliant resource, you can use CloudTrail to find out who made the change that caused the non-compliance. CloudTrail gives you the 'who, what, when', and Config gives you the 'what's the state now' and 'what was the state then'. Together, they provide a complete picture of your account's security and operational health.

GuardDuty is the third service in this triad. GuardDuty is a threat detection service. It uses machine learning and integrated threat intelligence to monitor your AWS environment for suspicious activity. It analyses CloudTrail logs, VPC Flow Logs (network traffic logs), and DNS logs to identify patterns like unusual API calls, crypto mining activity, or compromised EC2 instances communicating with known malicious IP addresses. GuardDuty is not covered in as much depth as CloudTrail and Config in this chapter, but it is a critical part of the auditing and governance puzzle. It is the 'guard dog' that barks when something looks wrong, based on the data collected by CloudTrail.

For the exam, you need to understand the security benefits of each service. CloudTrail provides accountability and forensic analysis. Config provides compliance and configuration history. GuardDuty provides intelligent threat detection. They are often used together in a 'detect and respond' architecture. You also need to know about CloudTrail log file integrity validation, which is a feature that uses digital signatures to ensure the log files have not been tampered with after they were created. Config aggregators allow you to view compliance data from multiple accounts and regions in a single place, which is critical for organisations managing many AWS accounts.

This flowchart shows how API calls flow into CloudTrail, how resource changes are evaluated by Config, and how both feed into GuardDuty for threat detection.

Walk-Through

1

Enable CloudTrail for your account

Log into the AWS Management Console, navigate to CloudTrail, and create a trail. Choose a name for the trail and select 'Apply trail to all regions' to create a multi-region trail. This ensures every API call from every region is recorded. You must also specify an S3 bucket where the log files will be stored. This bucket must have the proper permissions for CloudTrail to write to it. This is the foundational step for all auditing.

2

Enable Log File Integrity Validation

While creating the trail, check the box that says 'Enable log file integrity validation'. This creates a digest file in a separate folder in your S3 bucket. This digest contains SHA-256 hashes of your log files. You can later use the AWS CLI command 'validate-logs' to verify that no one has tampered with the logs. This is a common exam requirement for compliance-heavy environments.

3

Enable AWS Config and define recording scope

Open the AWS Config console and click 'Get started'. Choose to record all resources in your region or specify specific resource types. You also choose the frequency of recording (e.g., every 1 hour or every 24 hours). Config will start taking snapshots of your resources and storing them in an S3 bucket and a DynamoDB table. You can also set up a configuration stream to send changes to a Lambda function for real-time reactions.

4

Apply Config rules for compliance

In the Config console, go to 'Rules' and add rules. Start with AWS managed rules like 's3-bucket-public-read-prohibited' and 'restricted-common-ports'. For custom requirements, create a custom rule using AWS Lambda. For example, write a Lambda function that checks if all EC2 instances have a specific tag. Config will evaluate your resources against these rules and report them as compliant or non-compliant in the dashboard.

5

Set up automated remediation for Config

For critical non-compliance issues, automate a response. In Config, when you create a rule, you can attach an automatic remediation action using AWS Systems Manager Automation or a custom Lambda function. For example, if a security group is made non-compliant by opening SSH to the world, Config can trigger a Lambda function that revokes that rule. This reduces the window of exposure without human intervention.

6

Enable GuardDuty and connect it to CloudTrail

Navigate to the GuardDuty console and enable it for your account. GuardDuty will automatically start analysing your CloudTrail management events (and optionally data events), VPC Flow Logs, and DNS logs. You do not need to configure it further — it uses machine learning models trained on AWS threat intelligence. If it detects suspicious activity, it generates a finding that you can view in the GuardDuty console and send to an alerting system like Amazon EventBridge.

What This Looks Like on the Job

Imagine you work as a DevOps engineer for a company called 'FinTech Corp', which handles financial data. The company has strict compliance requirements from auditors who want proof that no unauthorised person can access customer data. You have two AWS accounts: one for production and one for development.

Step one: You enable CloudTrail for both accounts, and crucially, you create a multi-region trail. This records every management API call from every region into a single S3 bucket named 'company-cloudtrail-logs'. You also enable log file integrity validation on this bucket, so auditors can verify the logs have not been altered. You then set up a CloudTrail dashboard in CloudWatch Logs (a monitoring service) to alert the security team whenever someone deletes a CloudTrail trail. An attacker might try to delete the trail to hide their actions.

Step two: You enable AWS Config in both accounts. You start by applying AWS managed rules: 's3-bucket-public-read-prohibited', 'ec2-instances-in-vpc', and 'iam-user-mfa-enabled'. These run automatically and check your resources every 24 hours. You also create a custom rule to check that all EC2 instances have a specific security group tag, because the finance team needs to track which application each instance belongs to.

Three months later, an auditor asks for a report of all security group changes over the last month. You go into AWS Config's timeline view for security groups and see exactly when each rule was added or removed. For each change, you click a button in the Config console that says 'Related CloudTrail events', which shows you exactly which IAM user made the change. The auditor is satisfied.

Later, an engineer accidentally makes an S3 bucket public. Within minutes, Config detects the change and marks it as non-compliant. An automated remediation action (a Lambda function) is triggered, making the bucket private again. CloudTrail then logs the original action (the engineer making it public) and the remediation action (the Lambda function making it private). You use CloudTrail to find the engineer and provide retraining. Without CloudTrail and Config, you would have no idea who made the change or that the bucket was ever public.

Or consider a security incident. GuardDuty detects unusual traffic from an EC2 instance to a known malicious IP address. It generates a finding. You go to CloudTrail to see what API calls that instance's role has made recently. You find that it has been making calls to create IAM users — a clear sign of compromise. You then use CloudTrail to trace back to the source of the compromise: the instance was created by a developer who left two years ago, and their access keys were still active. You can then disable those keys and patch the security hole.

How DOP-C02 Actually Tests This

The DOP-C02 exam tests CloudTrail and Config thoroughly. Expect to see these concepts questioned in multiple-choice questions and scenario-based questions where you must choose the right combination of services for a given business requirement.

Here are the key areas the exam focuses on:

CloudTrail management events vs data events: The exam loves to ask whether a particular action is a management or data event. Remember: management events are free by default and cover actions like creating or deleting resources. Data events are chargeable and cover actions like reading or writing objects within resources (e.g., GetObject in S3, Invoke in Lambda). A trap question might ask: 'Which type of CloudTrail event records a user uploading a file to an S3 bucket?' The correct answer is 'data event', because the upload is an action on an object inside the bucket, not on the bucket itself.

Multi-region trails: The exam expects you to know that a multi-region trail collects events from all regions into a single S3 bucket. A single-region trail only collects events from one region. If an auditor needs a single source of truth for global events, you must enable a multi-region trail.

Log file integrity validation: This is a common question. It uses SHA-256 hashing and digital signatures to create a digest file that proves your CloudTrail logs have not been tampered with. The exam asks: 'How do you verify that CloudTrail logs have not been altered?' The answer is log file integrity validation.

Config managed vs custom rules: The exam tests your ability to choose when to use a managed rule (AWS pre-built) versus a custom rule (written by you in Lambda). Managed rules cover common compliance checks like 'is encryption enabled?'. Custom rules are needed for organisation-specific policies, like 'all EC2 instances must have a tag called 'cost-centre'.

Config recording vs evaluation: Config records the configuration state of resources continuously. It evaluates resources against rules. A question might ask: 'What does Config use to determine if a resource is compliant?' The answer is a Config rule (managed or custom).

GuardDuty integration: The exam asks how GuardDuty uses CloudTrail logs as a data source. GuardDuty analyses management events from CloudTrail to detect suspicious API patterns, such as a user making many failed login attempts or an EC2 instance making unusual API calls.

CloudTrail delivery to CloudWatch Logs: You can send CloudTrail events to CloudWatch Logs for real-time monitoring and alerting based on specific patterns (e.g., 'root account activity'). The exam tests that this is optional and must be configured.

Config aggregators: If you need to view compliance across multiple accounts and regions, you use a Config aggregator. The exam tests that this is the tool for multi-account, multi-region compliance views.

Traps: A common trap is confusing CloudTrail with Config. A question might say: 'You need to track configuration changes to EC2 instances over time.' A beginner might choose CloudTrail because it tracks changes, but the better answer is Config, because it maintains a history of configurations. CloudTrail tracks the API call that made the change, not the resulting configuration state. Another trap: CloudTrail events are not real-time — there is a delay (typically 15 minutes) between the action and the event appearing in the trail. Config can be near-real-time if you enable configuration stream delivery.

Key definitions to memorise:

CloudTrail: records API calls (who, what, when).

Config: records resource configurations (state).

GuardDuty: threat detection using machine learning.

Management events: actions on resources (free).

Data events: actions inside resources (paid).

Multi-region trail: one trail for all regions.

Log file integrity validation: verifies log authenticity.

Config rule: defines compliance criteria.

Config aggregator: views compliance across accounts.

Key Takeaways

CloudTrail records every API call in your AWS account, providing a tamper-proof audit trail of who did what and when.

CloudTrail management events are free and enabled by default, but data events (like S3 object uploads) must be explicitly enabled and incur costs.

AWS Config tracks the configuration state of your resources over time, allowing you to see what changed and when, not just who made the change.

Config rules evaluate your resources against desired policies and can automatically remediate non-compliant resources when combined with Lambda.

GuardDuty analyses CloudTrail logs, VPC Flow Logs, and DNS logs using machine learning to detect threats like compromised instances or suspicious API calls.

Log file integrity validation on CloudTrail uses SHA-256 hashing and digital signatures so you can prove your audit logs have not been altered.

Multi-region trails are essential for organisations operating in multiple AWS regions, because they centralise all events into a single S3 bucket for global auditing.

Config aggregators let you view compliance data across multiple AWS accounts and regions from a single dashboard, which is critical for enterprise environments.

Easy to Mix Up

These come up on the exam all the time. Here's how to tell them apart.

CloudTrail

Records API calls (who did what)

Captures every action immediately

Focuses on operational auditing and forensics

AWS Config

Records resource configuration state (current and historical)

Takes periodic snapshots of configurations

Focuses on compliance and configuration drift detection

Management Events (CloudTrail)

Actions that affect resources (e.g., create, delete)

Free by default for one trail per region

Covered by default when you enable CloudTrail

Data Events (CloudTrail)

Actions inside resources (e.g., read object from S3)

Paid per 100,000 events

Must be explicitly enabled on a per-resource basis

Managed Config Rules

Pre-built by AWS for common compliance checks

No coding required to use them

Limited to AWS-defined compliance logic

Custom Config Rules

Written by you using AWS Lambda

Require programming skills to create

Fully customisable to your organisation's policies

CloudTrail Log File Integrity Validation

Generates a SHA-256 hash digest file

Allows cryptographic proof of log authenticity

Recommended for compliance-heavy environments

Standard CloudTrail Logs

No additional verification mechanism

Logs can be modified if S3 bucket permissions are compromised

Sufficient for non-critical operational use

Watch Out for These

Mistake

CloudTrail logs everything, so I don't need Config.

Correct

CloudTrail logs API calls, not the resulting state of resources. Config tracks the actual configuration state and its history. For example, CloudTrail logs the API call 'AuthorizeSecurityGroupIngress' but does not show you what the security group's rules look like now. Config does that.

Beginners think 'auditing' means just recording actions. They don't realise that knowing the state of a resource after the action is equally important for compliance and troubleshooting.

Mistake

CloudTrail events are available immediately in real-time.

Correct

CloudTrail events are delivered within about 15 minutes of the API call. They are not real-time. For near-real-time monitoring, you can send events to CloudWatch Logs, but there is still a slight delay.

People are used to instant feedback in IT. They assume a log service works like a video camera. In reality, CloudTrail batches events before delivery to reduce cost and overhead.

Mistake

If I enable CloudTrail, I must pay for all events.

Correct

Management events are free by default and always enabled. Data events (like S3 object-level actions) are charged additionally. You can also create a trail that only records management events and incur no cost.

AWS has a reputation for being expensive. Beginners assume that enabling a 'security' feature will automatically increase their bill. They do not understand the free tier structure of CloudTrail.

Mistake

Config rules automatically fix non-compliant resources.

Correct

Config only detects and reports non-compliant resources. It does not automatically fix them unless you configure automatic remediation using AWS Systems Manager or Lambda. By default, it just marks the resource as non-compliant.

The word 'compliance' implies enforcement. Beginners expect Config to act like a firewall that blocks bad configurations. In reality, it is a detective, not a preventive, tool unless you explicitly build automation on top of it.

Mistake

GuardDuty is the same as CloudTrail because they both monitor activity.

Correct

CloudTrail records raw API call data. GuardDuty analyses that data (along with VPC Flow Logs and DNS logs) using machine learning to identify threats. CloudTrail is the data source; GuardDuty is the intelligence layer on top.

Both services deal with 'monitoring', so beginners lump them together. They do not grasp the layered security model where one service provides raw logs and another provides analysis.

Mistake

I only need CloudTrail if I have compliance requirements.

Correct

CloudTrail is essential for operational troubleshooting, security incident response, and change management, even without external compliance mandates. It helps you answer 'who changed what and when' for any issue in your account.

Beginners see auditing as a 'nice to have' for auditors only. They do not recognise its practical value in daily operations, like debugging why an application stopped working after a permissions change.

Do You Actually Know This?

Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.

Frequently Asked Questions

What is the difference between CloudTrail and AWS Config?

CloudTrail records API calls — who did what and when. AWS Config records the state of your resources — what the configuration looks like at any point in time. CloudTrail is for auditing actions; Config is for tracking configuration drift and compliance.

Do I need to enable CloudTrail separately for each region?

No. You can create a single multi-region trail that automatically extends to all current and future regions. This is the recommended best practice for comprehensive auditing. If you only create a single-region trail, you will miss events from other regions.

How much does CloudTrail cost?

Management events (the default) are free for one copy per region. Data events (like S3 object-level logs) are charged per 100,000 events. You also pay for the S3 storage and, optionally, for CloudWatch Logs delivery. For most small accounts, CloudTrail costs are minimal.

Can AWS Config automatically fix a non-compliant resource?

Yes, but only if you configure automatic remediation. By default, Config only detects and reports non-compliance. You can attach a Systems Automation document or a Lambda function to automatically change the resource back to a compliant state, but this is an optional, additional configuration.

Is CloudTrail secure from tampering?

Yes, if you enable Log File Integrity Validation. This feature creates a cryptographic hash digest that you can use to verify that your log files have not been altered after they were created. Without this feature, anyone with write access to the S3 bucket could theoretically modify the logs.

Do I need CloudTrail if I use AWS Config?

Yes, they serve different purposes. Config tells you your current configuration state. CloudTrail tells you who made the changes to get to that state. For a complete audit trail, you need both. For example, Config will tell you a security group became non-compliant, but only CloudTrail will tell you which IAM user made the change.

What are CloudTrail management events?

Management events are API calls that create, modify, or delete AWS resources. Examples include 'RunInstances' (launching an EC2 instance) or 'CreateBucket' (creating an S3 bucket). They are recorded by default and are free.

Terms Worth Knowing

Keep going

You've finished Auditing and Governance with AWS CloudTrail and Config. Continue through the DOP-C02 study guide to build a complete picture of the exam.

Done with this chapter?