Sub topic 16
Guardrails: permissions boundaries and SCPs
This chapter assumes you can read IAM policy JSON and know how identity-based policies and explicit deny work. Both features here set a maximum on permissions. Neither grants any permission itself.
Two guardrails, two scopes
| Guardrail | Attached to | Limits |
|---|---|---|
| Permissions boundary | One IAM user or role | That identity only |
| Service control policy (SCP) | An AWS Organizations root, OU, or account | Every user and role in the affected member accounts, including each account's root user |
A permissions boundary is a managed policy you set on a user or role. The identity can do only what its identity-based policies allow and the boundary allows. Delegated administrators often use this to let developers create roles without letting them escalate privileges.
An SCP works the same way at the account level. It sets the maximum permissions for the accounts it covers. SCPs do not apply to the management account. They also do not apply to service-linked roles.
A boundary in practice
This boundary allows only S3 and CloudWatch actions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:*", "cloudwatch:*"],
"Resource": "*"
}
]
}Attach it when you create the user:
aws iam create-user \
--user-name dev-user \
--permissions-boundary arn:aws:iam::111122223333:policy/DevBoundaryNow give dev-user an identity policy that allows ec2:* and s3:GetObject. Only s3:GetObject works, because EC2 is outside the boundary. If the user has no identity policy, the boundary alone grants nothing.
How the layers combine
The diagram shows the layers for an identity-based request. Session policies, when used, add one more intersection.
Common errors
- Expecting an SCP to grant access. An SCP that allows
s3:*gives no one S3 access. An identity or resource policy must still allow it. - Removing the default
FullAWSAccessSCP. If you do this without attaching another allow, every action in the account is implicitly denied. Teams usually keep it and add explicit Deny SCPs instead. - Assuming the boundary limits resource policies. In the same account, a resource-based policy that names the user or role ARN as principal is not limited by the boundary.
- Debugging only the identity policy. An implicit deny may come from the boundary or an SCP. Check all layers.
Exercise
A role has an identity policy allowing dynamodb:* and a permissions boundary allowing only s3:*. Can the role call dynamodb:GetItem? What if the account's SCP allows everything?
Show answer
No in both cases. The boundary does not allow DynamoDB, so the request is an implicit deny. The SCP can only restrict, so allowing everything does not override the boundary.