The bucket waits in silence, holding terabytes of data you need but cannot risk exposing. Access must be clean, verifiable, and locked to read-only. That is where Open Policy Agent (OPA) meets AWS S3 roles.
Using OPA for AWS S3 read-only roles gives you full control over who can see what, and when. You define policies as code, test them before deployment, and enforce them at the edge. No hidden permissions. No accidental writes.
Start by creating an IAM role in AWS with the s3:GetObject and s3:ListBucket actions. Attach this role to your application or service identity. This ensures AWS allows only the read operations you specify.
OPA sits between your application and AWS’s SDK or API calls. You write a Rego policy that inspects the request context—user identity, request path, resource tags—and returns allow = true only if the role matches your rules. Everything else is denied.