Sub topic 4
What an SCP is and what it is not
This chapter assumes you know how IAM identity-based policies work and can read policy JSON (Effect, Action, Resource, Condition). It also assumes you know the organization tree of a root, OUs, and accounts, and that you have enabled the SCP policy type on the root. By the end you should be able to say what a service control policy (SCP) does, and just as importantly what it never does.
The one-sentence definition
An SCP sets the maximum permissions that principals in member accounts can have. It is a filter on what IAM could otherwise allow. It does not give anyone access to anything.
That last point causes the most mistakes. You can attach an SCP that says Allow for s3:* to an account, and no user or role in that account gains any S3 access. Someone still has to write an IAM policy that grants it. The SCP only says the grant is permitted to take effect.
SCPs are a boundary, not a grant
Think of two circles. One circle holds every action your IAM policies grant to a principal. The other holds every action the SCPs permit for that account. The principal can use only the actions in the overlap.
| Source | Actions |
|---|---|
| IAM policies on the role | `s3:*`, `ec2:*` |
| SCPs allow | `s3:*`, `iam:*` |
| Effective permissions | `s3:*` |
Here ec2:* is granted by IAM but not allowed by the SCP, so it is blocked. The role never receives iam:* because no IAM policy grants it, even though the SCP allows it.
An SCP never allows something by itself, so a principal needs two things for an action to succeed:
- An IAM policy (or other grant mechanism) that allows it.
- No SCP that blocks it, with an allow present at every level of the tree.
Where SCPs apply
SCPs are attached to the root, to an OU, or to an account. They affect principals in the member accounts that fall under that target. This includes:
- IAM users and IAM roles in those accounts.
- The root user of each member account.
- Roles assumed from elsewhere, once they are acting inside the member account.
The effect lands on the account of the principal making the request. If a role in account A is restricted by an SCP, that restriction follows the role's requests wherever they go, including calls to resources in other accounts. The SCP on account B, where the resource lives, does not restrict a caller from account A. Controlling who can reach your resources is the job of resource control policies, which are covered in a later chapter.
Some other identities are also outside SCP control, such as service-linked roles. The chapter "What SCPs do not restrict" lists them in full, so this chapter does not repeat that list.
Allow statements and the default FullAWSAccess policy
When you enable the SCP type, AWS attaches a managed policy named FullAWSAccess to the root, to every OU, and to every account. Its content is:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}This policy is what keeps your accounts working after SCPs are enabled. It allows everything, so the overlap with IAM is whatever IAM grants. Nothing changes until you add something more restrictive.
The rule that follows from this is important. For an action to be possible, an allow must exist at every level between the root and the account. If you detach FullAWSAccess from an OU and attach nothing in its place, that OU has no allow. Every request from every account under it is then denied by default, because SCPs use implicit deny just like IAM does.
You can list the SCPs in your organization and see which ones are AWS managed:
aws organizations list-policies --filter SERVICE_CONTROL_POLICYWhat goes in an SCP
An SCP is a JSON document in IAM policy style, with these differences from an identity-based policy:
- There is no
Principalelement. The policy applies to whatever accounts it is attached to, not to named principals. If you need to treat some roles differently, use aConditionon a key such asaws:PrincipalArn. - The statement usually uses
Effect,Action(orNotAction),Resource, and optionallyCondition. - Deny statements support the full range of those elements. Allow statements have had stricter syntax limits in the past. Check the current Organizations documentation for what your policy may contain before relying on a specific element in an
Allow. - Size is limited. A policy can be at most 5,120 characters, and a target can have only a limited number of SCPs attached (the default quota is five per root, OU, or account). Check current quotas, since they can change. White space counts toward the character limit, so compact your JSON if you get close.
Because of the size limit and the attachment quota, a strategy that relies on many small allow lists tends to hit limits faster than a strategy that relies on a few deny statements. Strategies are the subject of a later chapter.
What an SCP cannot do
The following table collects the misunderstandings that most often cause failed rollouts.
| Belief | Reality |
|---|---|
| An SCP gives a role access | It never does. IAM must grant the access. |
| An SCP blocks everything in the account, including other principals' access to its resources | It restricts only principals in the accounts it applies to. Outside principals are not limited by it. |
| An SCP restricts the management account | It does not. |
| An SCP can name a principal | There is no `Principal` element. Use conditions instead. |
| Removing a deny is enough to regain access | Access also needs an IAM grant and an allow at every level of the tree. |
| An SCP is a replacement for IAM policies | It is a guardrail. You still write IAM policies for day-to-day permissions. |
A worked trace
Suppose a developer role in account 111111111111 has this identity-based policy:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:*", "ec2:*"],
"Resource": "*"
}
]
}The account sits in an OU named Sandbox. The root has only FullAWSAccess. The Sandbox OU has a custom SCP that allows only s3:* and iam:*, and its FullAWSAccess is detached.
- The developer calls
s3:ListAllMyBuckets. IAM allows it, and the OU SCP allows it. The root also allows it throughFullAWSAccess. The request is permitted. - The developer calls
ec2:RunInstances. IAM allows it, but the OU SCP has no allow forec2actions. There is no match, so implicit deny applies and the request fails. - The developer calls
iam:CreateUser. The SCP allows it, but the role's IAM policy does not grant it. The request fails for lack of an IAM grant.
Cases 2 and 3 fail for different reasons. In case 2 the guardrail blocks the call. In case 3 the missing grant blocks it. Keeping those apart helps when you debug.
Common errors
- Assuming an SCP allow is enough. A new team reports they cannot use a service even though the SCP permits it. Check the IAM policy first.
- Forgetting the management account. A guardrail looks correct in tests, but an admin in the management account can still violate it. This is by design.
- Dropping the default allow. Removing
FullAWSAccessin one step is the fastest route to an outage. - Expecting an SCP to control inbound access. If an outside principal reads one of your buckets through a bucket policy, your SCP does not stop that request.
- Overlooking the size limit. Long lists of services or ARNs can push a policy past 5,120 characters.
Exercise
A role in a member account has an IAM policy allowing dynamodb:*. The OU above the account has FullAWSAccess detached and a single SCP that allows only s3:*. Can the role call dynamodb:ListTables? Explain which part of the evaluation blocks it, or why it succeeds.
Show answer
No. IAM grants the action, but the OU has no SCP allow covering dynamodb:*. SCPs use implicit deny, so with no matching allow at that level, the request is denied.
Exercise
An administrator attaches an SCP that allows iam:* to an account and says the account's developers now have IAM access. What is wrong with this claim, and what else is needed?
Show answer
An SCP never grants permissions. It only sets the maximum. The developers also need an identity-based policy (or another grant) that allows the IAM actions. The SCP simply stops them from being blocked at the organization level.
Exercise
Why does an SCP attached to the root not restrict an administrator who signs in to the management account?
Show answer
SCPs affect only principals in member accounts. The management account is exempt from SCPs, regardless of where they are attached.