Sub topic 4
What an SCP is and what it is not
This chapter assumes you know how IAM identity-based policies work, can read policy JSON (Effect, Action, Resource, Condition), and understand the organization tree of a root, OUs, and accounts. It also assumes the SCP policy type is already enabled on the root.
What an SCP does
A service control policy (SCP) sets the maximum permissions that principals in member accounts can have. A principal is an IAM user or role. An SCP works as a filter. It removes permissions from the pool that IAM policies can grant, and it never adds any.
This is the most common misunderstanding about SCPs. An SCP that contains "Effect": "Allow" for s3:* does not give anyone S3 access. It only says that S3 actions are allowed to pass through this layer. A principal still needs an identity-based or resource-based policy that grants the action.
Two ways to read the same rule
Consider a role in a member account. Its IAM policy grants ec2:* and s3:*. An SCP in the account's path allows only s3:*. The role can use S3, but its EC2 calls fail, even though its own policy allows them.
| IAM policy grants | SCP allows | Result |
|---|---|---|
| s3:GetObject | s3:GetObject | Allowed |
| s3:GetObject | Nothing for S3 | Denied |
| Nothing | s3:GetObject | Denied (no grant) |
| s3:GetObject | Explicit Deny on s3:GetObject | Denied |
An explicit Deny in an SCP always wins, as it does everywhere else in IAM.
Where SCPs apply
SCPs affect principals in member accounts. Several details matter in practice:
- They apply to the IAM users and roles in the accounts they are attached to, including the account's root user.
- They apply to every principal in the account, whether or not it was created before the SCP was attached.
- They do not apply to the management account. Even if you attach an SCP to the root or to the management account, it has no effect there. For that reason, avoid running workloads in the management account.
- They limit what principals can do. They do not limit who can access your resources from outside, which is the job of resource control policies, covered in a later chapter.
The next chapter covers the other exemptions, such as service-linked roles.
The default FullAWSAccess policy
When you enable SCPs, AWS attaches a managed SCP named FullAWSAccess to the root, to every OU, and to every account. It allows all actions on all resources. Because of it, nothing is blocked until you add a Deny statement.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "*",
"Resource": "*"
}
]
}If you remove FullAWSAccess and attach nothing in its place, every action in the affected accounts is implicitly denied. The reason is that an SCP must allow an action at every level of the tree, from the root down to the account, for the action to be permitted. Chapter material on deny-list and allow-list strategies builds on this.
A first example
This SCP stops principals in member accounts from leaving the organization:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyLeavingOrganization",
"Effect": "Deny",
"Action": "organizations:LeaveOrganization",
"Resource": "*"
}
]
}Attach this alongside FullAWSAccess. The Allow from FullAWSAccess lets everything through, and this Deny removes one action. Principals in the affected accounts get an explicit-deny error if they try to call LeaveOrganization, even if their IAM policy grants organizations:*.
Common mistakes
- Expecting an SCP Allow to grant access. It never does.
- Testing a new SCP from the management account and concluding it has no effect. The management account is exempt.
- Removing
FullAWSAccesswithout first attaching another SCP that allows the actions you need. - Forgetting that an SCP applies to every principal in the account, including administrators and the account root user.
Exercise
A role in a member account has an IAM policy that allows dynamodb:*. The SCPs on its OU and account contain only FullAWSAccess and a Deny on dynamodb:DeleteTable. Can the role create a table, and can it delete one?
Show answer
It can create a table, because FullAWSAccess allows the action and the IAM policy grants it. It cannot delete a table, because the SCP's explicit Deny on dynamodb:DeleteTable overrides the IAM Allow.
Exercise
You attach an SCP that allows only s3:* to a member account and remove FullAWSAccess. A role there has an IAM policy granting AdministratorAccess. Which actions can the role perform?
Show answer
Only S3 actions, assuming no other SCP in the path blocks them. The SCP limits the maximum permissions, so the role's other administrator permissions are filtered out. The SCP does not give the role S3 access. The IAM policy does.