A Deep Dive into AWS CloudTrail
Who made changes to sensitive parts of your cloud infrastructure? Capture audit logs with AWS CloudTrail. Learn how to analyze the audit logs with the help of CloudWatch Logs Insights or Athena. On top of that, we discuss how to rollout CloudTrail to all AWS accounts belonging to your organization. Last but not least, you will learn about the blind spots and how to avoid extensive costs.
What to expect from the video?
- Demo: Querying audit logs with CloudWatch
- Demo: Querying audit logs with Athena
- Best practices for configuring CloudTrail (multi-account)
- About blind spots: S3, DynamoDB, SQS, SNS, …
- About extensive costs: data events are expensive
- Demo: Real-time alerts (CIS AWS Foundations)
Enjoy the video!
Capturing and storing audit logs is only half of the job. It would be best if you were capable of analyzing the logs as well.
Querying audit logs with CloudWatch
Here are some examples of queries for CloudWatch Logs Insights.
Which regions are used within account?
fields |
Are IAM users used to access resources?
fields @timestamp, @message |
Who signed in through the AWS Management Console?
fields @timestamp, @message |
Which IAM policies have been changed?
fields @timestamp, @message |
Detect changes to Security Groups.
fields @timestamp, @message |
Did anyone make use of leaked AWS credentials?
fields @timestamp, @message |
Querying audit logs with Athena
Besides that, Athena offers a powerful way to search through audit logs captured by CloudTrail as well.
Creating the table to analyze CloudTrail logs
Make sure to replace $BUCKETNAME with the name of the S3 bucket that you are storing CloudTrail logs in. Also you need to update the list of AWS accounts near projection.account.values.
CREATE EXTERNAL TABLE cloudtrail_logs_pp( |
Detect changes to Security Groups.
SELECT * FROM "default"."cloudtrail_logs_pp" WHERE eventsource = 'ec2.amazonaws.com' AND eventname IN ('AuthorizeSecurityGroupEgress', 'AuthorizeSecurityGroupIngress', 'RevokeSecurityGroupEgress', 'RevokeSecurityGroupIngress') AND account = '068189904525' and timestamp > '2021/01/01' limit 50; |
CloudTrail Data Events
Copy our spreadsheet to calculate costs for CloudTrail Data Events.
Realtime Alerts
Our CloudFormation template cloudtrail.yaml includes the realtime alerts as defined in the CIS AWS Foundations Benchmark.