Skip to content
IAM Policy Generator

IAM policy example: give each user an S3 home folder, with a least privilege rewrite

Allows each IAM user to list and use only the prefix named after the user inside one bucket, using the aws:username policy variable. The variable resolves per caller, so one policy serves every user. The rewrite removes the wildcard on the object actions and keeps the prefix condition.

Open the workbench ยท All examples

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListOwnPrefix",
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket",
      "Condition": {
        "StringLike": {
          "s3:prefix": [
            "home/${aws:username}/*"
          ]
        }
      }
    },
    {
      "Sid": "OwnObjects",
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/home/${aws:username}/*"
    }
  ]
}

What it allows

  • The first statement lists only keys that start with home/ and the caller's user name.
  • The second statement allows every S3 action on objects under that same prefix.

What it allows

  1. Allow 1 action (s3:ListBucket) on arn:aws:s3:::amzn-s3-demo-bucket when s3:prefix StringLike home/${aws:username}/*.

    Action or patternActionsAccess levels
    s3:ListBucket1List 1
  2. Allow 180 actions (s3:*) on arn:aws:s3:::amzn-s3-demo-bucket/home/${aws:username}/*.

    Action or patternActionsAccess levels
    s3:*180List 18, Read 66, Write 57, Permissions management 27, Tagging 12

Checks

No flags from the six checks.

The object statement uses s3:*, which covers 180 actions, including ACL and tagging changes on the home folder.

Least privilege rewrite

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListOwnPrefix",
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket",
      "Condition": {
        "StringLike": {
          "s3:prefix": [
            "home/${aws:username}/*"
          ]
        }
      }
    },
    {
      "Sid": "OwnObjects",
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject",
        "s3:DeleteObject"
      ],
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/home/${aws:username}/*"
    }
  ]
}

The rewrite replaces s3:* with three object actions. Users keep read, write and delete in their own folder but cannot change object ACLs or tags.

What it allows

  1. Allow 1 action (s3:ListBucket) on arn:aws:s3:::amzn-s3-demo-bucket when s3:prefix StringLike home/${aws:username}/*.

    Action or patternActionsAccess levels
    s3:ListBucket1List 1
  2. Allow 3 actions (s3:GetObject, s3:PutObject, s3:DeleteObject) on arn:aws:s3:::amzn-s3-demo-bucket/home/${aws:username}/*.

    Action or patternActionsAccess levels
    s3:GetObject1Read 1
    s3:PutObject1Write 1
    s3:DeleteObject1Write 1

Checks

No flags from the six checks.

Sources

  1. Amazon S3 User Guide: bucket policy and user policy walkthrough, read 16 Nov 2026
  2. Amazon S3 User Guide: identity-based 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.