Sub topic 9
How SCPs and RCPs Fit into Request Evaluation
This chapter assumes you can read IAM policy JSON and know the difference between identity-based and resource-based policies. It also assumes you have seen the ideas of inheritance and "maximum permissions" from the earlier chapters. Here you will put the pieces together into one model: what AWS checks, in what order, and in whose account.
The core rule: guardrails filter, they never grant
SCPs and RCPs only limit what is possible. Neither one gives a principal access to anything.
- An SCP sets the maximum permissions for IAM principals (users and roles) in member accounts.
- An RCP sets the maximum permissions on resources in member accounts.
- Real access still needs an Allow from an identity-based policy, a resource-based policy, or both, depending on the case.
A request succeeds only if every layer that applies to it lets it through and no layer contains an explicit deny.
Evaluation order
When a request arrives, AWS evaluates all applicable policies together. The effective order is:
- Explicit deny. A matching Deny in any policy (SCP, RCP, identity, resource, boundary, session) ends evaluation with a denial.
- RCPs. The request must be allowed by the RCPs that apply to the resource's account.
- SCPs. The request must be allowed by the SCPs that apply to the principal's account.
- Resource-based policy. It can grant access, and for same-account requests it can be enough on its own.
- Identity-based policy. It must allow the action unless a resource-based policy already grants it.
- Permissions boundary, if the principal has one.
- Session policy, if the session has one.
If any step that requires an allow finds none, the result is an implicit deny.
Which account's guardrails apply
This is the part that most often confuses people. SCPs follow the principal. RCPs follow the resource.
| Guardrail | Evaluated against | Taken from | Covers principals outside the organization? |
|---|---|---|---|
| SCP | The calling principal | The principal's account and its parent OUs and root | No. It only restricts principals in member accounts. |
| RCP | The resource being accessed | The resource's account and its parent OUs and root | Yes. It applies to any principal that calls the resource. |
Consider a role in account A calling s3:GetObject on a bucket in account B. Both accounts are in the same organization.
- A's SCPs apply, because the role lives in A.
- B's RCPs apply, because the bucket lives in B.
- B's SCPs do not apply to this request. They govern B's own principals, and the caller is not one of them.
- A's RCPs do not apply to this request. They govern A's resources, and the bucket is not one of them.
For a cross-account request, an allow is needed on both sides. The role's identity-based policy in A must allow the action, and the bucket policy in B must allow the role.
Now take a caller from an account outside your organization that reads your bucket through a permissive bucket policy. No SCP of yours applies, because the caller is not in your organization. Only an RCP on the bucket's account can stop that request. This is why RCPs exist.
Walking through a request
The policy below is a bucket policy that opens a bucket to a partner account. The partner account is not in your organization.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PartnerRead",
"Effect": "Allow",
"Principal": { "AWS": "arn:aws:iam::222222222222:root" },
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-reports/*"
}
]
}On its own, this works if the partner's own IAM policy allows s3:GetObject. Now attach the identity-perimeter RCP from the Topic Spine to the OU that holds the bucket's account:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyNonOrgPrincipalsOnS3",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": {
"aws:PrincipalOrgID": "o-exampleorgid"
},
"BoolIfExists": {
"aws:PrincipalIsAWSService": "false"
}
}
}
]
}The partner's request now meets the RCP's Deny. The RCP matches because the principal's organization ID is not o-exampleorgid and the caller is not an AWS service. AWS stops at step 1. The bucket policy's Allow is never reached. Neither the bucket owner's policy nor the partner's IAM policy can override the denial.
If the partner access is legitimate, the RCP needs an exception, for example another condition on the partner's account ID. Removing the bucket policy would not help.
Scenarios
The table shows how the layers combine for a few common cases. "Grant" means an Allow exists in the policy type named.
| Case | SCP | RCP | Identity policy | Resource policy | Result |
|---|---|---|---|---|---|
| Same account, role has S3 permission | Allows | Allows | Grants | None | Allowed |
| Same account, bucket policy names the role | Allows | Allows | None | Grants | Allowed. A resource policy can be enough in the same account. |
| Role has admin rights, SCP denies the Region | Denies | Allows | Grants | None | Denied |
| SCP allows, but no policy grants the action | Allows | Allows | None | None | Denied (implicit) |
| Cross-account, only the bucket policy grants | Allows | Allows | None | Grants | Denied. The caller's account must also grant. |
| Outside caller, bucket policy grants, RCP blocks non-org principals | Not applied | Denies | n/a | Grants | Denied |
Allow statements in guardrails do not grant
Every organization starts with the AWS-managed FullAWSAccess SCP and the RCPFullAWSAccess RCP attached. These policies allow everything, so that guardrails have no effect until you add denies. Two consequences follow:
- An SCP with
"Effect": "Allow"fors3:*does not give anyone S3 access. It only avoids filtering S3 out. - In an allow-list design you detach the full-access policy and list what is permitted. Anything not listed is then implicitly denied at the guardrail layer, even for an administrator.
Inheritance still applies. At every level between the root and the account, the request must be allowed by at least one policy at that level. An Allow on the account does not rescue a request that an OU above it did not allow.
What falls outside the guardrails
Remember the exemptions from earlier chapters, because they change the evaluation:
- SCPs do not restrict the management account's principals, and RCPs do not apply to resources in the management account. Do not keep workloads there.
- SCPs do not restrict service-linked roles. RCPs likewise do not apply to calls made by service-linked roles.
- SCPs only apply to principals in member accounts, so they cannot block outside callers. Use an RCP for that.
- RCPs only cover the services AWS lists as supported. For an unsupported service, a resource-side control has no effect, so check the current list before you rely on one.
Reading the result
Denial messages tell you which layer fired, which is the fastest way to apply this model. Exact wording varies by service, but typical forms are:
- "with an explicit deny in a service control policy": an SCP statement matched a Deny.
- "with an explicit deny in a resource control policy": an RCP statement matched a Deny.
- "because no service control policy allows the ... action": an SCP allow-list left the action out. This is an implicit denial.
- "because no identity-based policy allows the ... action": the guardrails passed, but nothing granted access.
CloudTrail records the failed call with the error message and the principal and resource, so you can see which account's guardrails to inspect. Start with the principal's account for an SCP message, and with the resource's account for an RCP message.
Common mistakes
- Expecting an SCP to block outside callers. SCPs never see principals outside the organization. Use an RCP.
- Expecting an RCP to restrict what your own roles can do. RCPs filter access to resources. They do not limit your principals' use of unsupported services or resources in other accounts.
- Treating Allow in a guardrail as a grant. Allows in an SCP or RCP only widen what the guardrail does not filter.
- Inspecting the wrong account. For cross-account calls, the SCPs are in the caller's account, and the RCPs are in the resource's account.
- Forgetting the explicit-deny rule. A Deny in an RCP beats an Allow in a bucket policy, and a Deny in an SCP beats an administrator policy.
Exercise
A role in account A (in your organization) reads an object from a bucket in account B (also in your organization). The role's IAM policy allows s3:GetObject, and the bucket policy allows the role. The request is denied with "explicit deny in a resource control policy". Which account's policies do you inspect first, and why would changing the bucket policy not fix it?
Show answer
Inspect the RCPs that apply to account B, because RCPs follow the resource and the bucket lives in B. Look at the RCPs on account B and on every OU and the root above it. An explicit deny takes precedence over any Allow, so editing the bucket policy cannot help. You must change the RCP (for example by adding an exception to its condition) or detach it.
Exercise
A caller from an account outside your organization uses a bucket policy that grants them s3:GetObject on your bucket. Can an SCP in your organization block this, and what can?
Show answer
No. SCPs only restrict principals in member accounts of your organization, and this caller is not one. An RCP on the bucket's account can block it, for example the identity-perimeter RCP that denies principals whose aws:PrincipalOrgID is not your organization.