Sub topic 11
Service control policies in AWS Organizations
This chapter assumes you know how identity-based policies, resource-based policies, and explicit deny work (covered in earlier chapters). You should also know what an AWS account is and be able to read policy JSON.
What an SCP is
A service control policy (SCP) is a policy you attach to an AWS Organizations root, an organizational unit (OU), or a single member account. It sets the maximum permissions that principals in the affected accounts can have. Like a permission boundary, an SCP grants nothing by itself. It only limits what identity policies and resource policies can grant.
Three facts define how SCPs behave:
- They affect IAM users and roles in member accounts, including the account's root user.
- They do not affect the management account. Principals there are never limited by SCPs, so keep workloads out of it.
- They do not affect service-linked roles, and they do not limit actions taken by principals in other accounts. They limit only the principals inside the accounts they apply to.
An SCP does not apply to resources directly. It applies to the requesting principal's account. If a principal in an SCP-restricted account reads from a bucket in another account, the SCP of the principal's account is evaluated. The bucket owner's SCPs are not evaluated for that principal's request, because the principal is not in the bucket owner's account. (Resource control policies, covered in a later chapter, address the resource side.)
Where SCPs fit in the evaluation
AWS first gathers every policy that applies to the request. Then it evaluates them in this order of concern:
- Is there an explicit deny in any applicable policy? If yes, the request is denied.
- Does an SCP allow the action? If the account is in an organization and the SCP does not allow it, the request is denied.
- Do the other layers (resource policy, permission boundary, session policy, identity policy) produce an allow, as described in earlier chapters?
The key idea is that an SCP is one more gate that the request must pass. It is not a source of permissions.
The effective permissions rule
Think of effective permissions as an intersection:
- The SCP allows action X, and
- the identity policy (or the resource policy, in the cases covered earlier) allows action X, and
- no layer denies action X.
If either the SCP or the identity policy is missing the action, the result is an implicit deny. The SCP can never add an action that the identity policy lacks.
| SCP allows | Identity policy allows | Result |
|---|---|---|
| Yes | Yes | Allow |
| Yes | No | Implicit deny |
| No | Yes | Implicit deny |
| Any | Any, with explicit Deny anywhere | Explicit deny |
The FullAWSAccess default and how inheritance works
When you enable SCPs, AWS attaches a managed SCP named FullAWSAccess to the root, to every OU, and to every account. It contains an allow for all actions on all resources:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}This default is why enabling SCPs does not break anything at first. Every level allows everything, so the intersection is everything.
SCP inheritance works like this: for an action to be allowed in an account, an SCP in the path from the root down to the account must allow it at every level. That means each of these must allow the action:
- the root,
- each OU between the root and the account,
- the account itself.
If any level has no allow for the action, the request is denied. Allows do not pass downward as grants. They must be present at each level.
Two common strategies
Deny list (the default approach). Keep FullAWSAccess attached at every level and add SCPs that contain explicit Deny statements for what you want to block. This is easy to maintain, since new AWS services are allowed automatically and you block only what you must.
Allow list. Detach FullAWSAccess and attach SCPs that allow only specific services or actions. This is stricter, but the allow must exist at every level of the path. If you remove FullAWSAccess from an OU and attach an allow list there, you must also make sure the root and the account levels still allow those actions. Allow lists need more upkeep because each new service you want to use requires a policy change.
A frequent mistake is detaching FullAWSAccess from the root or an OU without attaching a replacement. The result is that every principal in that subtree is denied everything, including actions that identity policies allow.
Example: deny actions outside approved Regions
This SCP denies requests made to any Region other than us-east-1 and eu-west-1. It exempts global services, because those are not tied to a Region and would otherwise break.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyOutsideApprovedRegions",
"Effect": "Deny",
"NotAction": [
"iam:*",
"organizations:*",
"sts:*",
"support:*",
"cloudfront:*",
"route53:*"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": ["us-east-1", "eu-west-1"]
}
}
}
]
}Reading it:
NotActionwithDenymeans "deny everything except these actions."- The condition key
aws:RequestedRegionholds the Region the request is sent to. StringNotEqualsis true when the Region is not in the list, so the deny applies only outside the approved Regions.
Because this is an explicit deny, no identity policy in the member account can override it, even if that policy allows ec2:* on *.
Example: protect a guardrail role
A second common use is stopping anyone in a member account from tampering with a security role, except one trusted administrator role.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ProtectSecurityAuditRole",
"Effect": "Deny",
"Action": [
"iam:DeleteRole",
"iam:DeleteRolePolicy",
"iam:PutRolePolicy",
"iam:AttachRolePolicy",
"iam:DetachRolePolicy",
"iam:UpdateAssumeRolePolicy"
],
"Resource": "arn:aws:iam::*:role/SecurityAudit",
"Condition": {
"ArnNotLike": {
"aws:PrincipalArn": "arn:aws:iam::*:role/OrgSecurityAdmin"
}
}
}
]
}Even an account administrator with AdministratorAccess cannot change SecurityAudit, unless they act as OrgSecurityAdmin. This is the typical pattern for guardrails: an explicit deny with a condition that names the exception.
Worked scenario
An account sits in the Workloads OU. The root has FullAWSAccess. The Workloads OU has only an SCP that allows s3:* and ec2:* (FullAWSAccess was detached from it). The account itself has FullAWSAccess. A role in the account has an identity policy that allows s3:GetObject, ec2:RunInstances, and dynamodb:GetItem.
Evaluate each action:
s3:GetObject: the root allows it, the OU allows it, the account allows it, and the identity policy allows it. Allow.ec2:RunInstances: same reasoning. Allow.dynamodb:GetItem: the identity policy allows it, but the OU's SCP does not include DynamoDB. The path is broken at the OU level. Implicit deny.
The role's own policy looked correct, which is why this kind of failure confuses people. The cause sits in a different account and a different policy type.
Limits and edge cases
- Conditions in SCPs are supported on
Denystatements and onAllowstatements with limits that vary by feature. For allow statements, keep to simple forms and test them. Conditions onDenyare the safest and most common use. - Resource-based policy grants to the same account are still limited. In a member account, a bucket policy that names a role in that same account cannot override an SCP block on the role's action. The SCP applies to the principal.
- Cross-account access needs both sides. The principal's account SCP must allow the action. The resource account's policies must also allow the principal.
- The management account is exempt. SCPs attached to the root or an OU do not restrict principals in the management account.
- Root user in member accounts is limited. An SCP can block actions even for the root user of a member account.
- Size limits apply. An SCP document has a maximum size, and an entity can have a limited number of attached SCPs. Combine statements and use wildcards to stay within them.
- SCPs do not grant permissions to anyone. If you find yourself writing an SCP to make something work, you are using the wrong tool. Use an identity or resource policy.
Checking SCPs when debugging
When a request is denied and the identity policy looks right, check the organization:
- In the AWS Organizations console, open the account and review the policies inherited from the root and each OU.
- Look at the CloudTrail event for the failure. A denial caused by an SCP names it in the error message ("with an explicit deny in a service control policy") for explicit denies. An implicit deny from a missing SCP allow can look like an ordinary missing permission.
- The IAM policy simulator can include SCPs when you test in an organization context, but confirm by looking at the actual attached policies.
Exercise
An account is in an OU. The root and the account both have FullAWSAccess attached. The OU has FullAWSAccess detached and has one SCP that allows only "s3:*". A role in the account has an identity policy allowing "s3:PutObject" and "sqs:SendMessage". Which of the two actions succeed, and why? What single change on the OU would let both succeed with the least effort?
Show answer
s3:PutObject succeeds because the root, the OU, the account, and the identity policy all allow it. sqs:SendMessage fails with an implicit deny because the OU's SCP does not allow SQS, so the allow chain is broken at the OU level, even though the identity policy allows it. The least-effort fix is to re-attach FullAWSAccess to the OU (or add an allow for sqs:* to the OU's SCP). No change to the role's identity policy helps.
Exercise
A developer with AdministratorAccess in a member account cannot create an EC2 instance in ap-southeast-2. The identity policy has no deny. Name the most likely cause and where you would look to confirm it.
Show answer
An SCP attached to the root, an OU in the path, or the account probably denies actions outside approved Regions (for example with a Deny on aws:RequestedRegion). Confirm by reviewing the SCPs inherited by the account in AWS Organizations and by reading the CloudTrail event for the failed call, whose error message mentions an explicit deny in a service control policy.