Skip to content
IAM Policy Generator

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

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.

Open the workbench ยท All examples

{
  "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.

What it allows

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

    Action or patternActionsAccess levels
    s3:Put*40Write 23, Permissions management 12, Tagging 5

Checks

No flags from the six checks.

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

Least privilege rewrite

{
  "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.

What it allows

  1. Allow 1 action (s3:PutObject) on arn:aws:s3:::amzn-s3-demo-bucket/* when s3:x-amz-server-side-encryption StringEquals aws:kms.

    Action or patternActionsAccess levels
    s3:PutObject1Write 1
  2. Allow 2 actions (kms:GenerateDataKey, kms:Decrypt) on arn:aws:kms:us-east-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab.

    Action or patternActionsAccess levels
    kms:GenerateDataKey1Write 1
    kms:Decrypt1Write 1

Checks

No flags from the six checks.

Sources

  1. Amazon S3 User Guide: security best practices, read 16 Nov 2026
  2. Amazon S3 User Guide: bucket policy examples, read 16 Nov 2026
  3. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.