# IAM policy example: require KMS encryption on S3 uploads, with a least privilege rewrite

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

Allows uploads to one bucket only when the request asks for server-side encryption with AWS KMS. The s3:x-amz-server-side-encryption condition key must equal aws:kms, so unencrypted PutObject calls fail. The original allows every S3 put action under that condition. Resource names and account 111122223333 are placeholders used in AWS documentation.

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PutEncryptedOnly",
      "Effect": "Allow",
      "Action": "s3:Put*",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
      "Condition": {
        "StringEquals": {
          "s3:x-amz-server-side-encryption": "aws:kms"
        }
      }
    }
  ]
}
```

## What it allows

- Allows S3 put actions on objects in the bucket when the request sets server-side encryption to aws:kms.

- Allows 40 actions (s3:Put*) on arn:aws:s3:::amzn-s3-demo-bucket/* when s3:x-amz-server-side-encryption StringEquals aws:kms.

Checks:
- No flags.

The wildcard s3:Put* covers 40 actions, including ACL, tagging and lock changes, not only object uploads.

## Least privilege rewrite

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "PutEncryptedOnly",
      "Effect": "Allow",
      "Action": "s3:PutObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
      "Condition": {
        "StringEquals": {
          "s3:x-amz-server-side-encryption": "aws:kms"
        }
      }
    },
    {
      "Sid": "UseKey",
      "Effect": "Allow",
      "Action": [
        "kms:GenerateDataKey",
        "kms:Decrypt"
      ],
      "Resource": "arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab"
    }
  ]
}
```

The rewrite limits the allow to PutObject and adds the two KMS actions the upload needs on one named key. The caller can no longer change object ACLs or tags.

- Allows 1 action (s3:PutObject) on arn:aws:s3:::amzn-s3-demo-bucket/* when s3:x-amz-server-side-encryption StringEquals aws:kms.
- Allows 2 actions (kms:GenerateDataKey, kms:Decrypt) on arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab.

Checks:
- No flags.

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

## Related pages

- [IAM policy example: list S3 buckets in the console](/examples/s3-list-buckets-console/)
- [IAM policy example: upload to one S3 prefix](/examples/s3-upload-only-prefix/)
- [IAM policy example: limit S3 access to a VPC endpoint](/examples/s3-access-only-from-vpc-endpoint/)
- [All of them](/examples/)

## Sources

- Amazon S3 User Guide: security best practices: https://docs.aws.amazon.com/AmazonS3/latest/userguide/security-best-practices.html (read 16 Nov 2026)
- Amazon S3 User Guide: bucket policy examples: https://docs.aws.amazon.com/AmazonS3/latest/userguide/example-bucket-policies.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-put-with-kms-encryption/

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