Read-only roles in AWS S3 sound simple. They aren’t. Debug logging for those roles is the difference between knowing exactly who touched your data and guessing in the dark. Without the right setup, you could leak sensitive details or miss critical access attempts entirely. Done right, you’ll see every request, every key, every referrer—without granting a single extra permission.
Defining S3 Read-Only Roles
An S3 read-only role is built to allow listing and reading objects—nothing more. The least privilege principle demands you start with "s3:GetObject" and "s3:ListBucket" actions and nothing else. Attach this to a role and trust it only from the accounts or services you control. But roles alone don’t give you visibility into what they are doing.
Enabling S3 Server Access Logging
To debug, enable S3 Server Access Logging on the bucket. This writes request logs to another bucket you own. Use strict write-only permissions on that log bucket so no one tampers with evidence. Logs record the requester, resource, action, and result. Pair logs with a unique IAM role session name so you can trace exactly which read-only role made the call.
Using CloudTrail for API-Level Insight
CloudTrail complements S3 logging by capturing full API events. Turn on data event logging for S3 in CloudTrail. This records the API calls made by the IAM role, including parameters, time, and error codes. Store CloudTrail logs in a separate monitoring account or a hardened bucket for long-term forensic analysis.