Sub topic 11
Service control policies in AWS Organizations
This chapter assumes you know how identity-based policies, resource-based policies, and permission boundaries combine, and that you have used AWS Organizations at a basic level (an organization, a management account, member accounts, and organizational units).
What an SCP does
A service control policy (SCP) is a policy you attach to an organization root, an organizational unit (OU), or a single member account. It sets the maximum permissions available in every account beneath that attachment point.
An SCP never grants access. It works like a permission boundary, but it applies to the whole account instead of to one role. A principal can perform an action only if the SCP allows it and the principal's own policies also allow it.
SCPs have three properties that surprise people:
- They affect every IAM user and role in the member accounts, including the account's root user.
- They do not affect the management account of the organization. Principals there are not restricted by SCPs.
- They do not affect service-linked roles, which AWS services use to work on your behalf.
How SCPs are inherited
Evaluation walks down the tree. A request from a member account must be allowed at the root, at each OU on the path, and at the account itself. If any level lacks an allow for the action, the result is an implicit deny.
Two strategies: deny list and allow list
By default, AWS attaches an SCP named FullAWSAccess to the root, every OU, and every account. It allows all actions, so a new organization restricts nothing until you change it.
The common approach is a deny list. Keep FullAWSAccess in place and add SCPs with explicit Deny statements. Because an explicit deny overrides any allow, the restriction holds at every level below.
The stricter approach is an allow list. Remove FullAWSAccess and attach SCPs that allow only the services you approve. Every level must then allow each action, so you need to maintain more policies.
Example: deny actions outside approved Regions
This SCP denies all actions when the request targets a Region outside the approved list. The NotAction element exempts global services, which would otherwise fail because they do not run in a specific Region.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyOutsideApprovedRegions",
"Effect": "Deny",
"NotAction": [
"iam:*",
"organizations:*",
"route53:*",
"support:*",
"cloudfront:*"
],
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": ["eu-west-1", "eu-central-1"]
}
}
}
]
}An SCP uses the same JSON structure as other policies, but it has no Principal element. It applies to every principal in the affected accounts.
Effective permissions with an SCP
Suppose a role has an identity policy that allows s3:* and ec2:*. Its account has an SCP that allows only s3:* and dynamodb:*.
| Action | Identity policy | SCP | Result |
|---|---|---|---|
| `s3:GetObject` | Allow | Allow | Allowed |
| `ec2:RunInstances` | Allow | No allow | Denied |
| `dynamodb:GetItem` | No allow | Allow | Denied |
The effective permissions are the overlap, as with a permission boundary.
Resource-based policies and SCPs
A resource-based policy can grant access to a principal in the same account without an identity policy allow. An SCP still applies to that principal. If the SCP denies the action, the principal cannot perform it, whatever the resource policy says.
SCPs apply to the principal's account. For a cross-account request, the principal's account SCPs apply to the caller. SCPs on the resource's account do not restrict an outside caller unless a different control, such as a resource control policy, is used.
Common errors
- Expecting an SCP to grant access. An allow in an SCP only keeps the action available. A principal still needs an identity-based or resource-based allow.
- Testing in the management account. SCPs do not apply there, so a restriction appears not to work.
- Forgetting inheritance. An allow on a child OU does not override a missing allow on its parent in an allow-list design.
- Forgetting that an SCP denies even the root user of a member account.
Exercise
A member account sits in an OU. The root has FullAWSAccess, the OU has an SCP with an explicit Deny for ec2:TerminateInstances, and the account has FullAWSAccess. A role in the account has an identity policy that allows ec2:*. Can it call ec2:TerminateInstances, and why? Would the answer change if the same role were in the management account?
Show answer
It cannot. The OU's explicit Deny overrides the Allows from FullAWSAccess at the other levels, and the identity policy's allow cannot override a deny. In the management account the answer would change: SCPs do not apply there, so the identity policy's allow would be enough.