I set up a new Trail to test this. Process was this:
- Create new CloudTrail, enabling delivery to CloudWatch as @Tim suggested, and also enabled Data Events on S3. You may just want to enable Data Events on S3 and filter for the bucket in question, else you might generate a lot of logs!
- Copied some files into a test bucket (
foo.txt
)
- CloudWatch -> Log Groups -> My group -> "View in Log Insights"
Once logs start arriving I can easily do the following:
Find usage from my IP (if you know the IP replace 192.168.1.1):
fields @timestamp, @message
| filter sourceIPAddress == "192.168.1.1"
| sort @timestamp desc
| limit 20
Find activity from the role that I assume:
fields @timestamp, @message
| filter userIdentity.sessionContext.sessionIssuer.userName == "Admin"
| sort @timestamp desc
| limit 20
I can then expand any of the rows with the arrow on the left to find more useful fields. Any field can be added to the fields
list to make it display nicely, e.g. use IP & Role & Service to narrow down a search and show useful info:
fields @timestamp, eventName, eventType, requestParameters.bucketName, requestParameters.key, resources.0.ARN
| filter sourceIPAddress == "xx.xx.xx.xx" and userIdentity.sessionContext.sessionIssuer.userName == "Admin" and eventSource == "s3.amazonaws.com"
| sort @timestamp desc
| limit 100
Quick update: I logged into my backup storage account, to find an actual IAM user the key is:
filter userIdentity.userName == "iam-user-name"