Skip to content
IAM Policy Generator

IAM policy example: let a team create roles under one path, with a least privilege rewrite

Allows a team lead to create roles under the path /app-team/ and to attach only a short list of managed policies to them. The iam:PolicyARN condition key limits which policy ARNs can be attached. The original allows attaching any policy to roles on that path.

Open the workbench ยท All examples

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "TeamRoles",
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:DeleteRole",
        "iam:AttachRolePolicy",
        "iam:DetachRolePolicy",
        "iam:PutRolePolicy"
      ],
      "Resource": "arn:aws:iam::111122223333:role/app-team/*"
    }
  ]
}

What it allows

  • Allows creating and deleting roles under /app-team/ and attaching or writing any policy on them.

What it allows

  1. Allow 5 actions (iam:CreateRole, iam:DeleteRole, iam:AttachRolePolicy, iam:DetachRolePolicy, iam:PutRolePolicy) on arn:aws:iam::111122223333:role/app-team/*.

    Action or patternActionsAccess levels
    iam:CreateRole1Write 1
    iam:DeleteRole1Write 1
    iam:AttachRolePolicy1Permissions management 1
    iam:DetachRolePolicy1Permissions management 1
    iam:PutRolePolicy1Permissions management 1

Checks

No flags from the six checks.

A team member can create a role under the path, attach AdministratorAccess to it and assume it, which makes this a route to full access.

Least privilege rewrite

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "CreateTeamRoles",
      "Effect": "Allow",
      "Action": [
        "iam:CreateRole",
        "iam:DeleteRole",
        "iam:DetachRolePolicy"
      ],
      "Resource": "arn:aws:iam::111122223333:role/app-team/*"
    },
    {
      "Sid": "AttachApprovedPolicies",
      "Effect": "Allow",
      "Action": "iam:AttachRolePolicy",
      "Resource": "arn:aws:iam::111122223333:role/app-team/*",
      "Condition": {
        "ArnEquals": {
          "iam:PolicyARN": [
            "arn:aws:iam::aws:policy/ReadOnlyAccess",
            "arn:aws:iam::111122223333:policy/app-team-baseline"
          ]
        }
      }
    }
  ]
}

The rewrite removes PutRolePolicy and limits AttachRolePolicy to two named policy ARNs. A member can no longer attach an administrator policy.

What it allows

  1. Allow 3 actions (iam:CreateRole, iam:DeleteRole, iam:DetachRolePolicy) on arn:aws:iam::111122223333:role/app-team/*.

    Action or patternActionsAccess levels
    iam:CreateRole1Write 1
    iam:DeleteRole1Write 1
    iam:DetachRolePolicy1Permissions management 1
  2. Allow 1 action (iam:AttachRolePolicy) on arn:aws:iam::111122223333:role/app-team/* when iam:PolicyARN ArnEquals arn:aws:iam::aws:policy/ReadOnlyAccess or arn:aws:iam::111122223333:policy/app-team-baseline.

    Action or patternActionsAccess levels
    iam:AttachRolePolicy1Permissions management 1

Checks

No flags from the six checks.

Sources

  1. IAM User Guide: grant a user permissions to pass a role, read 16 Nov 2026
  2. IAM User Guide: create a role to delegate permissions to an IAM user, read 16 Nov 2026
  3. AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026

Last reviewed 16 Nov 2026.