# S3 bucket policy vs IAM policy

IAM policy examples · Updated 17 November 2026

**Short answer:** An IAM policy is attached to a user or role and says what that identity can do; a bucket policy is attached to the bucket and says who can access it, so it has a Principal. Within one account either is enough on its own. Across accounts, both the bucket policy and the caller's IAM policy must allow the request.

## A cross-account example that needs both

Account 111122223333 runs a role called `analytics` that must read `my-bucket` in account 123456789012. The bucket owner adds this bucket policy:

```
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AnalyticsList",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::111122223333:role/analytics"
      },
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::my-bucket"
    },
    {
      "Sid": "AnalyticsRead",
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws:iam::111122223333:role/analytics"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::my-bucket/*"
    }
  ]
}
```

And account 111122223333 attaches an IAM policy to the `analytics` role allowing the same two actions on the same two ARNs (see [read-only access to one bucket](https://cloudconsole.dev/iam/s3-read-only-one-bucket)). Remove either half and the request is denied.

## How they combine

| Situation | What has to allow it |
|---|---|
| Caller and bucket in the same account | The IAM policy *or* the bucket policy |
| Caller in another account | The bucket policy *and* the caller's IAM policy |
| Anonymous (public) access | Only a bucket policy can grant it, and Block Public Access must be off |
| Any explicit `Deny` in either | Denied, whatever else allows it |

SCPs, resource control policies, permissions boundaries, session policies and VPC endpoint policies can still deny a request that both documents allow.

## When to use which

- **Use IAM policies** for "what can this role do across many buckets": the access belongs to the job. You can see everything a role may do in one place.
- **Use a bucket policy** for rules about the bucket itself, whoever the caller is: cross-account access, CloudFront origin access control, [deny non-TLS requests](https://cloudconsole.dev/iam/s3-deny-http-requests), [only via a VPC endpoint](https://cloudconsole.dev/iam/s3-restrict-to-vpc-endpoint), or [require a KMS key](https://cloudconsole.dev/iam/s3-enforce-kms-encryption). Deny statements here protect the data even from admins in your own account.

Size limits differ too: a bucket policy can be up to 20 KB, while a customer managed IAM policy is limited to 6,144 characters (excluding whitespace), so very long lists of ARNs fit better on the bucket.

## Apply a bucket policy

```
aws s3api put-bucket-policy --bucket my-bucket \
  --policy file://bucket-policy.json

aws s3api get-bucket-policy --bucket my-bucket --query Policy --output text
```

In the console it is under the bucket's **Permissions** tab → **Bucket policy**. The console runs IAM Access Analyzer policy checks as you type, which catches most syntax problems.

## Common mistakes

- **No Principal.** A bucket policy statement without `Principal` is rejected as malformed. IAM policies must not have one.
- **`"Principal": "*"` with an Allow.** That is public access unless a condition narrows it. Block Public Access will refuse it on most accounts.
- **Granting the account root ARN and stopping there.** `arn:aws:iam::111122223333:root` delegates to that account; its admins still have to grant their roles in IAM.
- **Objects written by another account.** With ACLs enabled, the uploader can own the object and your bucket policy won't cover it. Set Object Ownership to *bucket owner enforced*.
- **KMS keys.** Cross-account reads of SSE-KMS objects also need the key policy to allow the other account.

## Questions

### Do I need both a bucket policy and an IAM policy?

Only for cross-account access. In the same account, an allow in either one is enough, as long as nothing explicitly denies the request.

### What is the Principal in an S3 bucket policy?

The identity the statement applies to: an account, a role or user ARN, a service principal such as cloudfront.amazonaws.com, or * for everyone.

### Which wins, bucket policy or IAM policy?

Neither wins outright. An explicit Deny in either always wins; otherwise the request needs the allows described above.

## When this happens away from your desk

Bucket access questions often arrive as a message from another team at an awkward hour. Being able to read the bucket policy and recent CloudTrail events from your phone settles most of them quickly.

[About the CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Identity-based policies and resource-based policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_identity-vs-resource.html)
- [Examples of Amazon S3 bucket policies](https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.html)
- [IAM and AWS STS quotas](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html)

## Related

- [IAM policy: read-only access to a single S3 bucket](https://cloudconsole.dev/iam/s3-read-only-one-bucket)
- [S3 bucket policy: deny requests that are not over HTTPS](https://cloudconsole.dev/iam/s3-deny-http-requests)
- [Cross-account assume role with an external ID](https://cloudconsole.dev/iam/cross-account-role-external-id)
- [aws s3api put-bucket-policy](https://cloudconsole.dev/cli/s3api-put-bucket-policy)
- [S3 AccessDenied: Access Denied when calling an S3 operation](https://cloudconsole.dev/errors/s3-access-denied)
- [How to find public S3 buckets](https://cloudconsole.dev/how-to/find-public-s3-buckets)

---

Source: https://cloudconsole.dev/iam/s3-bucket-policy-vs-iam-policy

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
