In this walkthrough, you’ll learn how to pinpoint the IAM user who terminated an EC2 instance (ID ends withDocumentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
1D91) using AWS CloudTrail’s Event History. This helps you audit critical API calls and enhance security visibility.
1. Access CloudTrail Event History
- Sign in to the AWS Management Console and search for CloudTrail.
- In the left-hand menu, select Event history.
- Adjust the time range and apply filters as needed to narrow down results.
CreateBucketPutBucketEncryptionConsoleLoginTerminateInstances
Ensure your IAM user or role has the
cloudtrail:LookupEvents permission to view event history.2. Filter for TerminateInstances Events
- In the Event name filter, type
TerminateInstances. - (Optional) Under Resource name, enter the instance ID:
TerminateInstances event for the target instance. The summary row displays the IAM user, timestamp, and event name.
3. Inspect Event Details
Click theTerminateInstances entry to expand the details pane. You’ll find several sections:
3.1 User Identity & Metadata
- IAM user John (
principalId:AIDAZZBPMTHEGGK6QLMU) - Event timestamp:
2023-10-16T17:25:20Z - API source:
ec2.amazonaws.com
3.2 Instance State Transition
Scroll down to Response elements to view the state change:| State | Code | Meaning |
|---|---|---|
| previousState | 16 | Running |
| currentState | 32 | Shutting-down |
TerminateInstances call initiated a shutdown.
4. Summary of Event Record
At the bottom of the details pane, you’ll find additional metadata:| Field | Sample Value | Description |
|---|---|---|
| eventID | 0ea6b2d5-51d5-4765-ad83-4db65d506d9c | Unique ID for the CloudTrail event |
| eventType | AwsApiCall | Type of API call |
| managementEvent | true | Indicates a management-level operation |
| recipientAccountId | 672261773768 | AWS account where the event occurred |
TerminateInstances API call, changing the instance from running to shutting-down.