Skip to content
IAM Policy Generator

IAM policy example: limit S3 access to a VPC endpoint, with a least privilege rewrite

Allows object reads and writes on one bucket only when the request arrives through one VPC endpoint, using the aws:SourceVpce condition key. Requests from the internet or other endpoints get no allow. The original uses an s3:* action, and the rewrite narrows it to three.

Open the workbench ยท All examples

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "FromEndpointOnly",
      "Effect": "Allow",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::amzn-s3-demo-bucket",
        "arn:aws:s3:::amzn-s3-demo-bucket/*"
      ],
      "Condition": {
        "StringEquals": {
          "aws:SourceVpce": "vpce-1a2b3c4d"
        }
      }
    }
  ]
}

What it allows

  • Allows every S3 action on the bucket and its objects when the request comes through the VPC endpoint vpce-1a2b3c4d.

What it allows

  1. Allow 180 actions (s3:*) on arn:aws:s3:::amzn-s3-demo-bucket, arn:aws:s3:::amzn-s3-demo-bucket/* when aws:SourceVpce StringEquals vpce-1a2b3c4d.

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

Checks

No flags from the six checks.

The network condition is sound, yet s3:* covers 180 actions, including bucket policy changes.

Least privilege rewrite

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListFromEndpoint",
      "Effect": "Allow",
      "Action": "s3:ListBucket",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket",
      "Condition": {
        "StringEquals": {
          "aws:SourceVpce": "vpce-1a2b3c4d"
        }
      }
    },
    {
      "Sid": "ObjectsFromEndpoint",
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:PutObject"
      ],
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
      "Condition": {
        "StringEquals": {
          "aws:SourceVpce": "vpce-1a2b3c4d"
        }
      }
    }
  ]
}

The rewrite keeps the endpoint condition on each statement and lists three actions. Bucket policy and delete actions are removed.

What it allows

  1. Allow 1 action (s3:ListBucket) on arn:aws:s3:::amzn-s3-demo-bucket when aws:SourceVpce StringEquals vpce-1a2b3c4d.

    Action or patternActionsAccess levels
    s3:ListBucket1List 1
  2. Allow 2 actions (s3:GetObject, s3:PutObject) on arn:aws:s3:::amzn-s3-demo-bucket/* when aws:SourceVpce StringEquals vpce-1a2b3c4d.

    Action or patternActionsAccess levels
    s3:GetObject1Read 1
    s3:PutObject1Write 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.