Mastering AWS CloudTrail: Scenario-Based Questions for Real-World Challenges

Mihir Popat
4 min read4 days ago

--

AWS CloudTrail is a crucial service for tracking API activity, ensuring compliance, and enhancing security within AWS environments. However, mastering CloudTrail requires more than just theoretical knowledge — it demands hands-on problem-solving skills.

In this article, we explore scenario-based AWS CloudTrail questions to help cloud engineers, security analysts, and DevOps professionals strengthen their AWS expertise. Each scenario is designed to challenge your ability to troubleshoot, secure, and optimize AWS environments.

Photo by Sebastian Herrmann on Unsplash

Scenario 1: Detecting Unauthorized Access in AWS

Question:

Your security team receives an alert that an IAM user executed a sensitive operation, such as deleting an S3 bucket, at an unusual hour. How would you investigate this incident using CloudTrail?

Solution:

  1. Identify the Activity:
  • Navigate to the AWS CloudTrail Console.
  • Search for DeleteBucket events under the Event history tab.
  • Filter by the event source s3.amazonaws.com.

2. Analyze the Request Parameters:

  • Check the userIdentity field to determine who performed the action.
  • Look at sourceIPAddress to see where the request originated.
  • Examine eventTime to verify when the operation occurred.

3. Validate Authorization:

  • Use AWS IAM Access Analyzer to determine if the IAM user had permissions.
  • Check IAM policies and roles assigned to the user.

4. Take Preventive Actions:

  • If unauthorized, disable the IAM user’s credentials.
  • Implement an S3 bucket policy to prevent accidental or unauthorized deletions.
  • Set up an Amazon SNS notification to alert security teams on similar events.

Scenario 2: Identifying Root User Activity

Question:

Your compliance team requires an audit of all actions taken by the root user in the last 90 days. How would you generate this report using CloudTrail?

Solution:

  1. Go to CloudTrail Event History:
  • Set the Time range filter to Last 90 days.
  • Use the advanced filter: userIdentity.type = Root.

2. Export Logs for Analysis:

  • Download the event history in CSV format for further review.
  • Use AWS Athena to query the CloudTrail logs in an S3 bucket.

3. Investigate Risky Actions:

  • Look for IAM policy changes, security group modifications, or account settings changes.
  • Identify failed login attempts under eventName = ConsoleLogin with errorMessage.

4. Enhance Security:

  • Enable MFA on the root account.
  • Restrict root access using Service Control Policies (SCPs) in AWS Organizations.
  • Configure an AWS Config rule to detect root account usage.

Scenario 3: Monitoring API Calls for Compliance

Question:

Your organization requires a continuous monitoring solution for API activity to meet compliance standards. How can you use AWS services to achieve this?

Solution:

  1. Enable AWS CloudTrail Logging:
  • Configure a multi-region CloudTrail to log API events across all AWS services.
  • Store CloudTrail logs in an Amazon S3 bucket with SSE-KMS encryption.

2. Use AWS CloudWatch for Real-Time Monitoring:

  • Create a CloudWatch Logs metric filter for specific API calls (e.g., RunInstances for EC2 launches).
  • Set up CloudWatch Alarms to trigger SNS notifications for critical API events.

3. Leverage AWS Security Hub & GuardDuty:

  • Use AWS Security Hub to get insights into suspicious API calls.
  • Enable Amazon GuardDuty to detect anomalies in CloudTrail logs.

4. Automate Incident Response with AWS Lambda:

  • Deploy a Lambda function that automatically revokes credentials if unauthorized access is detected.
  • Use AWS Step Functions for workflow automation in compliance audits.

Scenario 4: Troubleshooting a Missing CloudTrail Log

Question:

Your team notices that certain API events are missing from the CloudTrail logs. How do you debug this issue?

Solution:

  1. Verify CloudTrail Configuration:
  • Check if the correct event types (Management vs. Data events) are being logged.
  • Ensure CloudTrail is set to log all regions.

2. Inspect S3 Bucket Permissions:

  • Confirm that the CloudTrail S3 bucket policy allows logs to be written.
  • Check KMS key policies if logs are encrypted.

3. Check CloudTrail Quotas and Limits:

  • Ensure you haven’t exceeded the CloudTrail event quota.
  • Consider using Amazon Data Lake with Athena for extended log retention.

Scenario 5: Blocking Malicious Activity with AWS Organizations

Question:

A rogue IAM user is repeatedly making unauthorized API calls to terminate EC2 instances in multiple AWS accounts. How do you prevent this at an organizational level?

Solution:

  1. Implement Service Control Policies (SCPs):
  • Deny ec2:TerminateInstances globally except for trusted roles.
  • Example SCP:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": "ec2:TerminateInstances",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:PrincipalArn": "arn:aws:iam::123456789012:role/TrustedAdminRole"
}
}
}
]
}

2. Use AWS Config and AWS Lambda for Auto-Remediation:

  • Create an AWS Config rule to detect EC2 terminations.
  • Trigger a Lambda function that reverts the termination request.

3. Enable AWS CloudTrail Insights:

  • Identify abnormal API activity patterns.
  • Detect spikes in failed authorization requests.

Conclusion

AWS CloudTrail is a powerful tool for security, compliance, and operational visibility. By mastering scenario-based problem-solving, cloud professionals can effectively detect and respond to security threats, unauthorized access, and compliance violations.

These scenarios are designed to simulate real-world challenges, making them ideal for AWS interviews, certifications, and on-the-job troubleshooting.

What’s your most challenging CloudTrail use case? Let’s discuss in the comments!

Connect with Me on LinkedIn

Thank you for reading! If you found these DevOps insights helpful and would like to stay connected, feel free to follow me on LinkedIn. I regularly share content on DevOps best practices, interview preparation, and career development. Let’s connect and grow together in the world of DevOps!

--

--

Mihir Popat
Mihir Popat

Written by Mihir Popat

DevOps professional with expertise in AWS, CI/CD , Terraform, Docker, and monitoring tools. Connect with me on LinkedIn : https://in.linkedin.com/in/mihirpopat

No responses yet