All posts

One wrong IAM policy, and your S3 bucket is an open book.

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 le

Free White Paper

Open Policy Agent (OPA) + AWS IAM Policies: The Complete Guide

Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.

Free. No spam. Unsubscribe anytime.

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.

Continue reading? Get the full guide.

Open Policy Agent (OPA) + AWS IAM Policies: Architecture Patterns & Best Practices

Free. No spam. Unsubscribe anytime.

IAM Policy Conditions for Narrow Scoping

Add conditions to limit read-only roles to specific buckets, prefixes, or source IPs. Use aws:SourceIp, s3:prefix, and s3:delimiter to restrict patterns of access. Debug logging becomes far easier when the role’s scope is tight—you can quickly rule out unwanted activity.

Correlating Logs for True Debug Power

The magic happens when you combine S3 Server Access Logs and CloudTrail data. Use request IDs to match entries in both sources. This lets you confirm not only that an object was read, but also what tool or process triggered it. Correlation gives you the full story without granting write privileges.

Performance and Cost Considerations

Logging every read request can generate large volumes of data. Use automated lifecycle policies to move old logs to Glacier or delete them after compliance requirements are met. Watch CloudTrail costs for high-frequency reads, and scope data event logging to critical buckets only.

Security Benefits of Full Debug Logging

With read-only roles and full debug logging in place, incident response is faster and more precise. You can detect unusual access times, pinpoint abuse patterns, and prove compliance during audits—all without slowing down normal S3 operations.

Small changes in IAM policy and logging configuration make the difference between certainty and risk. Want to see how simple it can be to manage secure, observable S3 access? Try it live in minutes at hoop.dev and watch your roles, logs, and policies come together in a single, clear view.

Get started

See hoop.dev in action

One gateway for every database, container, and AI agent. Deploy in minutes.

Get a demoMore posts