A developer needs to grant an IAM user read-only access to an S3 bucket named 'my-bucket'. Which policy should be attached to the IAM user?
Trap 1: {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:…
Granting s3:ListBucket against the bucket ARN only permits the user to enumerate object keys and metadata, not to retrieve the bodies of any objects. This action is evaluated at the bucket level, while the actual data resides at the object level. To satisfy read-only access, an object-level action such as s3:GetObject on arn:aws:s3:::my-bucket/* is required, so this policy alone fails to meet the requirement.
Trap 2: {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:…
This policy grants s3:* for every resource, which includes administrative and destructive actions such as s3:DeleteObject, s3:PutBucketPolicy, and s3:PutObject. It goes far beyond read-only access and violates the principle of least privilege. With wildcards on both the action and the resource, the user could modify, delete, or reconfigure any S3 bucket in the account, not just the intended one.
Trap 3: {"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:…
s3:PutObject allows the user to upload or overwrite objects in the bucket, which is write access rather than read access. Even though the resource ARN correctly points to objects under my-bucket, the action is the opposite of what is needed for a read-only policy. A read-only policy must grant s3:GetObject on the object ARN, not s3:PutObject, which would let the user create new versions or replace existing object content.
- A
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:ListBucket","Resource":"arn:aws:s3:::my-bucket"}]}
Why wrong: Granting s3:ListBucket against the bucket ARN only permits the user to enumerate object keys and metadata, not to retrieve the bodies of any objects. This action is evaluated at the bucket level, while the actual data resides at the object level. To satisfy read-only access, an object-level action such as s3:GetObject on arn:aws:s3:::my-bucket/* is required, so this policy alone fails to meet the requirement.
- B
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:*","Resource":"*"}]}
Why wrong: This policy grants s3:* for every resource, which includes administrative and destructive actions such as s3:DeleteObject, s3:PutBucketPolicy, and s3:PutObject. It goes far beyond read-only access and violates the principle of least privilege. With wildcards on both the action and the resource, the user could modify, delete, or reconfigure any S3 bucket in the account, not just the intended one.
- C
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:PutObject","Resource":"arn:aws:s3:::my-bucket/*"}]}
Why wrong: s3:PutObject allows the user to upload or overwrite objects in the bucket, which is write access rather than read access. Even though the resource ARN correctly points to objects under my-bucket, the action is the opposite of what is needed for a read-only policy. A read-only policy must grant s3:GetObject on the object ARN, not s3:PutObject, which would let the user create new versions or replace existing object content.
- D
{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Action":"s3:GetObject","Resource":"arn:aws:s3:::my-bucket/*"}]}
This policy exactly implements read-only object access by allowing the s3:GetObject action on the objects within the bucket. The resource ARN arn:aws:s3:::my-bucket/* correctly scopes the action to object keys under my-bucket, rather than the bucket itself or all buckets. This grants the user the ability to retrieve object data and metadata while denying writes, deletions, or bucket-level administrative changes.