
How S3 decides allow or deny
For every request AWS evaluates all policies that apply: the caller's IAM policies, the bucket policy, any SCP from AWS Organizations, VPC endpoint policies and, for encrypted objects, the KMS key policy. An explicit Deny anywhere wins. Otherwise at least one policy must Allow the exact action (for example s3:GetObject) on the exact resource ARN.
A very common mistake is the ARN: arn:aws:s3:::my-bucket covers bucket actions such as ListBucket, while objects need arn:aws:s3:::my-bucket/*.
Causes and fixes
| Cause | Sign | Fix |
|---|---|---|
| IAM policy missing the action | Works for admin, fails for app role | Add s3:GetObject/PutObject on bucket/* |
| Wrong resource ARN | ListBucket works, GetObject fails (or the reverse) | Use both bucket and bucket/* ARNs |
| Bucket policy Deny | Denied even for admins; often a condition on VPC endpoint, IP or TLS | Read the bucket policy conditions |
| Block Public Access on | Public website or public file gives 403 | Prefer CloudFront with Origin Access Control; only turn off BPA deliberately |
| KMS key not allowed | Error mentions KMS, or only encrypted objects fail | Grant kms:Decrypt (and GenerateDataKey for uploads) in the key policy or IAM |
| Object owned by another account | Cross-account uploads unreadable | Set Object Ownership to "Bucket owner enforced" |
| Object does not exist and no ListBucket | 403 instead of 404 | Grant s3:ListBucket to see 404 for missing keys |
Fix it step by step
- Confirm who you are:
aws sts get-caller-identity. Many "bugs" are the wrong profile or role. - Reproduce with the CLI:
aws s3api get-object --bucket my-bucket --key path/file.txt out.txt. - Check the caller's IAM policy covers the action and the
bucket/*ARN. Test it in the IAM Policy Simulator. - Open the bucket policy and look for
"Effect": "Deny"with conditions such asaws:SourceVpce,aws:SecureTransportor IP ranges. - If the object is SSE-KMS encrypted, check the key policy allows the caller to decrypt.
- For public content, keep Block Public Access on and serve through CloudFront with Origin Access Control.
- Still stuck: find the denied call in CloudTrail (event
GetObjectwith errorCode AccessDenied); newer error messages also say which policy type denied it.
Questions
Why do I get 403 instead of 404 for a missing file?
Without s3:ListBucket permission S3 will not tell you whether the key exists, so it returns 403 for missing objects.
Should I turn off Block Public Access to fix 403?
Only for a deliberate public bucket. For websites, CloudFront with Origin Access Control keeps the bucket private and is the recommended setup.
Does an explicit Deny in the bucket policy beat an admin IAM policy?
Yes. An explicit Deny in any policy always wins over any Allow.