IAM policy example: let a team create roles under one path, with a least privilege rewrite
Facts read 16 Nov 2026. Page reviewed 16 Nov 2026.
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
Allow 5 actions (iam:CreateRole, iam:DeleteRole, iam:AttachRolePolicy, iam:DetachRolePolicy, iam:PutRolePolicy) on arn:aws:iam::111122223333:role/app-team/*.
Action or pattern Actions Access levels iam:CreateRole1 Write 1 iam:DeleteRole1 Write 1 iam:AttachRolePolicy1 Permissions management 1 iam:DetachRolePolicy1 Permissions management 1 iam:PutRolePolicy1 Permissions 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
Allow 3 actions (iam:CreateRole, iam:DeleteRole, iam:DetachRolePolicy) on arn:aws:iam::111122223333:role/app-team/*.
Action or pattern Actions Access levels iam:CreateRole1 Write 1 iam:DeleteRole1 Write 1 iam:DetachRolePolicy1 Permissions management 1 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 pattern Actions Access levels iam:AttachRolePolicy1 Permissions management 1
Checks
No flags from the six checks.
Related pages
Sources
- IAM User Guide: grant a user permissions to pass a role, read 16 Nov 2026
- IAM User Guide: create a role to delegate permissions to an IAM user, read 16 Nov 2026
- AWS Service Authorization Reference, programmatic access (fetched 16 Nov 2026), read 16 Nov 2026
Last reviewed 16 Nov 2026.