Sub topic 12
Resource control policies and VPC endpoint policies
This chapter assumes you know the core rule (default deny, explicit deny wins, otherwise at least one allow). It also assumes you know what SCPs and resource-based policies do. Two more guardrails remain. Neither grants permissions. Both only limit them.
Where these policies sit
A service control policy (SCP) limits what principals in your accounts can do. A resource control policy (RCP) limits what can be done to resources in your accounts. A VPC endpoint policy limits what can pass through one network path.
| Policy | Attached to | Limits | Grants access? |
|---|---|---|---|
| SCP | Organization root, OU, or account | Principals in member accounts | No |
| RCP | Organization root, OU, or account | Resources in member accounts | No |
| VPC endpoint policy | A VPC endpoint | Requests sent through that endpoint | No |
Resource control policies
An RCP is an AWS Organizations policy type that sets the maximum permissions available on resources in member accounts. It works as a ceiling, like an SCP. The difference is the direction. An SCP restricts your own principals. An RCP restricts anyone who touches your resources, including principals from outside your organization.
That makes RCPs useful for a data perimeter. For example, you can require that only identities from your organization can use your S3 buckets, even when a bucket policy is too permissive.
Key behaviors:
- RCPs support only certain services, such as Amazon S3, AWS STS, AWS KMS, Amazon SQS, and AWS Secrets Manager. Check the current list before relying on one.
- RCPs do not apply to resources in the management account.
- An RCP cannot grant access. An Allow in the RCP only keeps the permission available. The
RCPFullAWSAccesspolicy is attached by default for this reason. - In an RCP, the
Principalelement must be"*". Narrow it with conditions.
This RCP denies S3 access from principals outside the organization. It exempts AWS service principals:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnforceOrgIdentities",
"Effect": "Deny",
"Principal": "*",
"Action": "s3:*",
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": { "aws:PrincipalOrgID": "o-exampleorgid" },
"BoolIfExists": { "aws:PrincipalIsAWSService": "false" }
}
}
]
}VPC endpoint policies
A VPC endpoint lets resources in a VPC reach an AWS service without using the public internet. You can attach a resource-based policy to the endpoint. The default policy allows everything. A custom policy limits which actions, resources, and principals can use that endpoint.
This policy limits an S3 gateway endpoint to one bucket:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "OnlyReportsBucket",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::example-reports-bucket/*"
}
]
}With this endpoint policy, a request to a different bucket fails, even if the caller's identity policy allows it. The endpoint policy does not give the caller access to the reports bucket either. The identity policy and bucket policy must still allow it.
How they combine
The endpoint policy applies only when the request travels through the endpoint. The RCP applies to the resource wherever the request comes from. Both are evaluated alongside the policies you already know.
An explicit Deny in any of these policies ends the evaluation with a denial.
Common errors
- Expecting an RCP to grant access. It never does.
- Testing from the management account. RCPs do not apply to its resources.
- Forgetting that an endpoint policy also blocks requests to other services' resources, such as AWS-owned buckets that tools use for packages.
- Writing an RCP with a specific principal instead of
"*".
Exercise
An S3 bucket in a member account has a bucket policy that allows a role from an outside account. An RCP on the organization root denies S3 access when aws:PrincipalOrgID is not your organization's ID. Can the outside role read the bucket? Why?
Show answer
No. The RCP's explicit Deny applies to the resource, and it matches because the role is not in your organization. An explicit Deny overrides the bucket policy's Allow.