A proof of concept for AWS S3 read-only roles is a fast way to validate permissions before pushing changes into production. The goal: let approved identities list and get objects without any chance of overwriting, deleting, or adding new data. This protects critical files while giving users the visibility they need.
Step 1: Create the Read-Only IAM Policy
Define a policy with the minimum required actions. Use s3:GetObject and s3:ListBucket on the exact bucket ARN. For example:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::your-bucket-name",
"arn:aws:s3:::your-bucket-name/*"
]
}
]
}
Step 2: Attach Policy to a Role
Create a role in AWS IAM. Attach the read-only policy. Set the trusted entities to AWS services or cloud principals you expect to read data.
Step 3: Test the Role
Use the AWS CLI or SDK to assume the role. Run aws s3 ls s3://your-bucket-name and aws s3 cp s3://your-bucket-name/object-key ./local-file. Confirm that write operations fail with AccessDenied.