# IAM policy example: upload to one S3 prefix, with a least privilege rewrite

Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.

Allows a principal to write objects under the uploads/ prefix of one bucket and nothing else. The original uses s3:* on the whole bucket, a common first draft for an upload job. The rewrite allows two actions on the prefix: PutObject and AbortMultipartUpload.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "Uploads",
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::amzn-s3-demo-bucket",
        "arn:aws:s3:::amzn-s3-demo-bucket/*"
      ]
    }
  ]
}
```

## What it allows

- Allows every S3 action on the bucket and all of its objects.

- Allows 180 actions (s3:*) on arn:aws:s3:::amzn-s3-demo-bucket, arn:aws:s3:::amzn-s3-demo-bucket/*.

Checks:
- No flags.

The action s3:* covers 180 actions and the resource covers every key, so an upload job could read or delete all data.

## Least privilege rewrite

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "UploadsOnly",
      "Effect": "Allow",
      "Action": [
        "s3:PutObject",
        "s3:AbortMultipartUpload"
      ],
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/uploads/*"
    }
  ]
}
```

The rewrite allows PutObject and AbortMultipartUpload on the uploads/ prefix only. Reading, listing and deleting are removed.

- Allows 2 actions (s3:PutObject, s3:AbortMultipartUpload) on arn:aws:s3:::amzn-s3-demo-bucket/uploads/*.

Checks:
- No flags.

- [Paste it into the workbench](/)
- [Every S3 action and its access level](/actions/s3/)

## Related pages

- [IAM policy example: limit S3 access to a VPC endpoint](/examples/s3-access-only-from-vpc-endpoint/)
- [IAM policy example: read EC2 inventory](/examples/ec2-describe-read-only/)
- [IAM policy example: start and stop tagged EC2 instances](/examples/ec2-start-stop-own-tagged-instances/)
- [All of them](/examples/)

## Sources

- Amazon S3 User Guide: identity-based policy examples: https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-policies-s3.html (read 16 Nov 2026)
- Amazon S3 User Guide: security best practices: https://docs.aws.amazon.com/AmazonS3/latest/userguide/security-best-practices.html (read 16 Nov 2026)
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026): https://docs.aws.amazon.com/service-authorization/latest/reference/service-reference.html (read 16 Nov 2026)

Last reviewed 16 Nov 2026. Canonical: https://iampolicygenerator.com/examples/s3-upload-only-prefix/

This site is not affiliated with Amazon Web Services. AWS service and product names are used only to describe AWS services.
