Skip to content
IAM Policy Generator

IAM policy example: S3 bucket policy for TLS and org, with a least privilege rewrite

A bucket policy that denies every request not sent over TLS and allows reads only to principals in one AWS Organization, identified by aws:PrincipalOrgID. The original allows reads to any principal, with TLS enforced. The rewrite adds the organization condition to the allow.

Open the workbench ยท All examples

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyInsecureTransport",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::amzn-s3-demo-bucket",
        "arn:aws:s3:::amzn-s3-demo-bucket/*"
      ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      }
    },
    {
      "Sid": "PublicRead",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*"
    }
  ]
}

What it allows

  • The first statement denies every S3 action on the bucket and its objects for any request that is not sent over TLS.
  • The second statement allows any principal to read any object.

What it allows

  1. Deny 180 actions (s3:*) on arn:aws:s3:::amzn-s3-demo-bucket, arn:aws:s3:::amzn-s3-demo-bucket/* for AWS * when aws:SecureTransport Bool false.

    Action or patternActionsAccess levels
    s3:*180List 18, Read 66, Write 57, Permissions management 27, Tagging 12
  2. Allow 1 action (s3:GetObject) on arn:aws:s3:::amzn-s3-demo-bucket/* for AWS *.

    Action or patternActionsAccess levels
    s3:GetObject1Read 1

Checks

No flags from the six checks.

The allow with Principal * makes every object public, because the bucket policy trusts everyone.

Least privilege rewrite

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyInsecureTransport",
      "Effect": "Deny",
      "Principal": "*",
      "Action": "s3:*",
      "Resource": [
        "arn:aws:s3:::amzn-s3-demo-bucket",
        "arn:aws:s3:::amzn-s3-demo-bucket/*"
      ],
      "Condition": {
        "Bool": {
          "aws:SecureTransport": "false"
        }
      }
    },
    {
      "Sid": "OrgRead",
      "Effect": "Allow",
      "Principal": "*",
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::amzn-s3-demo-bucket/*",
      "Condition": {
        "StringEquals": {
          "aws:PrincipalOrgID": "o-exampleorgid"
        }
      }
    }
  ]
}

The rewrite adds aws:PrincipalOrgID so only principals in organization o-exampleorgid can read. Anonymous and outside callers lose access.

What it allows

  1. Deny 180 actions (s3:*) on arn:aws:s3:::amzn-s3-demo-bucket, arn:aws:s3:::amzn-s3-demo-bucket/* for AWS * when aws:SecureTransport Bool false.

    Action or patternActionsAccess levels
    s3:*180List 18, Read 66, Write 57, Permissions management 27, Tagging 12
  2. Allow 1 action (s3:GetObject) on arn:aws:s3:::amzn-s3-demo-bucket/* for AWS * when aws:PrincipalOrgID StringEquals o-exampleorgid.

    Action or patternActionsAccess levels
    s3:GetObject1Read 1

Checks

No flags from the six checks.

Sources

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

Last reviewed 16 Nov 2026.