Lesson 1 of 3 AWS CloudTrail

Answering Who Changed What with CloudTrail Events

This lesson explains how AWS CloudTrail records the API calls made in an account from the console, CLI, SDKs or AWS services, answering the operational question who changed what, and when.

Learning outcomes

After completing this lesson, you will be able to:

  • Interpret the fields of a CloudTrail event.
  • Distinguish management, data and Insights events.
  • Search event history.

What an event contains

Each CloudTrail event records the eventTime, eventSource (for example ec2.amazonaws.com), eventName (for example AuthorizeSecurityGroupIngress), awsRegion, sourceIPAddress, userAgent, the userIdentity of the caller (IAM user, assumed role session, root, AWS service), the requestParameters, the responseElements, and an errorCode and errorMessage when the call failed. Failed calls are recorded too, which makes CloudTrail the starting point for AccessDenied investigations.

Match the pairs

Reading an event

Exam skills 4.1.2

Match each question with the CloudTrail event field that answers it.

Log in to try this activity Interactive activities are free with an account.

Event types

CloudTrail distinguishes several types of event. Management events are control plane operations on resources, such as creating an instance, changing a security group or signing in to the console; they are recorded by default. Data events are high-volume data plane operations on or in a resource, such as S3 GetObject and PutObject, Lambda Invoke or DynamoDB item operations; they are not recorded unless a trail or event data store is configured for them, and they are charged. Network activity events record API calls made through VPC endpoints, including calls denied by endpoint policies. Insights events record unusual API call rates or error rates detected by CloudTrail Insights. The following table summarises them.

TypeExamplesRecorded by default
Management eventsRunInstances, DeleteBucket, ConsoleLogin, AttachRolePolicyYes (event history and trails)
Data eventsS3 GetObject/PutObject, Lambda Invoke, DynamoDB PutItemNo; enable on a trail, with selectors
Network activity eventsCalls through VPC endpoints, including denied callsNo; enable on a trail
Insights eventsUnusual volume of TerminateInstances or AccessDenied errorsNo; enable Insights

The following diagram shows the four event types and which are recorded by default.

The CloudTrail event types and whether each is recorded by default. Management events, the control plane operations, are recorded by default. Data events, network activity events and Insights events must be configured on a trail or event data store, and data events are charged.
Investigating object-level access in S3 is only possible if data events were enabled before it happened.
Sort into groups

Which event type?

Exam skills 1.1.1 · 4.1.2

Classify each activity as a management, data or Insights event.

Log in to try this activity Interactive activities are free with an account.

Event history

Event history is available in every account without setup. It shows the last 90 days of management events in the current Region, searchable by attributes such as event name, user name, resource name and event source, and downloadable as CSV or JSON. It does not include data events, it cannot be extended, and it is per Region. Anything beyond these limits requires a trail.

90days

Management events shown in event history, per Region

Worked example

Who opened port 22?

An AWS Trusted Advisor check reports that a security group allows SSH from 0.0.0.0/0. The operator searches event history for the event name AuthorizeSecurityGroupIngress and the security group ID as the resource name.

aws cloudtrail lookup-events --max-results 5 \
  --lookup-attributes AttributeKey=ResourceName,AttributeValue=sg-0a1b2c3d4e5f67890 \
  --query 'Events[].{time:EventTime,name:EventName,user:Username}'

The result shows that an assumed role session named ops-admin/jsmith added the rule two days ago. The full event's requestParameters confirm the CIDR and port. The operator removes the rule, and the team adds an AWS Config rule with automatic remediation to stop it happening again.

Check yourself

Are S3 object-level reads recorded by default?

Show answer

No. They are data events, which must be enabled explicitly on a trail and are charged.

Exam Tips

Remember for the exam

  • Event history: 90 days of management events per Region, free, no setup.
  • Data events (S3 object access, Lambda Invoke) must be enabled explicitly and are charged.
  • Failed calls are recorded with errorCode, which helps troubleshoot AccessDenied.
  • Network activity events record calls through VPC endpoints.