Sub topic 12
Resource control policies and VPC endpoint policies
This chapter covers two guardrails that limit access without granting it. A resource control policy (RCP) limits what can be done to resources in your AWS Organizations accounts. A VPC endpoint policy limits what can pass through one network path to an AWS service. It assumes you know the core rule (default deny, explicit deny wins, at least one allow), the difference between identity-based and resource-based policies, and how SCPs and permission boundaries act as ceilings.
Where these two policies fit
Every policy type so far answers one of two questions. Some say what a principal may do (identity policies, permission boundaries, SCPs, session policies). Others say who may use a resource (resource-based policies). RCPs and VPC endpoint policies add two more angles:
- An RCP is set per organization, OU, or account, and constrains the resources in the affected member accounts, whoever the caller is.
- A VPC endpoint policy is attached to one endpoint and constrains requests that travel through it.
Neither grants permission. Each can only remove access that other policies would have allowed. This matches the SCP and permission boundary pattern: a ceiling, not a grant.
| Policy | Attached to | Constrains | Grants access? |
|---|---|---|---|
| SCP | Organization root, OU, or account | Principals in member accounts | No |
| RCP | Organization root, OU, or account | Supported resources in member accounts | No |
| VPC endpoint policy | A VPC endpoint | Requests sent through that endpoint | No |
| Permission boundary | A user or role | That one identity | No |
Resource control policies
What an RCP does
An RCP sets the maximum permissions available on resources in member accounts. Think of it as the resource-side counterpart of an SCP. An SCP asks, "What may my principals do?" An RCP asks, "What may anyone do to my resources?"
The difference matters when the caller is outside your organization. An SCP only governs principals inside your accounts, so it cannot stop an outside principal from using a permissive bucket policy. An RCP is evaluated on the resource side, so it applies even when the caller belongs to another organization or account.
Properties to remember
- RCPs apply only to a supported list of services. At the time of writing this includes Amazon S3, AWS STS, AWS KMS, Amazon SQS, and AWS Secrets Manager. AWS adds services over time, so check the current list.
- They apply to resources in member accounts. They do not apply to resources in the management account.
- They do not apply to requests made by service-linked roles.
- They need the
RESOURCE_CONTROL_POLICYpolicy type to be enabled in the organization first. - Like SCPs, they work as an allow list under the hood. AWS attaches a managed
RCPFullAWSAccesspolicy to every root, OU, and account. If you remove it without replacing it, you deny everything that the RCP covers. - A request must be allowed by the RCPs at every level between the root and the resource's account. A Deny statement at any level wins.
- Statements need
"Principal": "*"and"Resource": "*". You narrow the effect withCondition.
An example: block outside principals
This RCP is a common starting point for a data perimeter. It denies access to the covered services unless the caller belongs to your organization or is an AWS service acting on your behalf.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "EnforceOrgIdentities",
"Effect": "Deny",
"Principal": "*",
"Action": ["s3:*", "sqs:*", "kms:*", "secretsmanager:*", "sts:*"],
"Resource": "*",
"Condition": {
"StringNotEqualsIfExists": { "aws:PrincipalOrgID": "o-exampleorgid" },
"BoolIfExists": { "aws:PrincipalIsAWSService": "false" }
}
}
]
}Read the condition carefully. Both condition operators must match for the Deny to apply.
aws:PrincipalOrgIDis not equal to your organization ID. TheIfExistssuffix makes the test also match when the key is absent, which is the case for anonymous callers.aws:PrincipalIsAWSServiceis false (or absent). This keeps AWS service principals, such as CloudTrail writing to your bucket, from being denied.
If you drop the service-principal test, you can break log delivery and other service-to-service calls that have no organization ID.
Managing RCPs from the CLI
aws organizations enable-policy-type \
--root-id r-examplerootid \
--policy-type RESOURCE_CONTROL_POLICY
aws organizations list-policies --filter RESOURCE_CONTROL_POLICYTest an RCP against a non-production OU before you attach it at the root. A Deny that is slightly too broad can interrupt services across every account.
VPC endpoint policies
What an endpoint policy does
A VPC endpoint lets resources in a VPC reach an AWS service without going over the public internet. Gateway endpoints (S3 and DynamoDB) and interface endpoints (most other services) can each carry a policy. The default policy allows everything through the endpoint, so an endpoint with the default policy limits nothing.
Once you write a custom policy, a request that goes through the endpoint must satisfy it, in addition to every other policy that applies. The policy does not grant access. A request that the endpoint policy allows still needs an Allow from the identity or resource policy, and it can still be stopped by an SCP, an RCP, or a boundary.
Properties to remember
- It only affects requests that use that endpoint. A caller with internet access can bypass the endpoint and reach the service another way unless you also deny that route.
- Endpoint policies use a
Principalelement, usually"*", because the policy is attached to a resource (the endpoint) rather than an identity. You narrow who it applies to with conditions. - Useful condition keys include
aws:PrincipalOrgID,aws:PrincipalAccount,aws:ResourceOrgID, andaws:ResourceAccount. These let you write rules like "only my organization's principals, only my organization's buckets." - Endpoint policies support Allow and Deny statements. A Deny wins here as it does everywhere.
An example: only your own bucket, only your own people
This endpoint policy allows read and write on one bucket, but only for principals in your organization.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowOrgPrincipalsToReportsBucket",
"Effect": "Allow",
"Principal": "*",
"Action": ["s3:GetObject", "s3:PutObject"],
"Resource": "arn:aws:s3:::example-reports-bucket/*",
"Condition": {
"StringEquals": { "aws:PrincipalOrgID": "o-exampleorgid" }
}
}
]
}Any other action or bucket requested through this endpoint is implicitly denied. That includes s3:ListBucket on the bucket itself, because the only Resource listed is the object path. If your applications list the bucket, add the bucket ARN and the action.
To see the policy an endpoint currently carries:
aws ec2 describe-vpc-endpoints \
--vpc-endpoint-ids vpce-0123456789abcdef0 \
--query "VpcEndpoints[0].PolicyDocument"Forcing traffic through the endpoint
Because an endpoint policy only sees traffic that uses the endpoint, pair it with a resource-side rule. A bucket policy Deny with aws:SourceVpce (or aws:SourceVpc) that does not match your endpoint forces access through it. Be careful: this also blocks the console and any caller outside the VPC, including you. Allow an administrative exception before you apply it.
How they fit in the evaluation flow
The full flow treats both policies as gates. Each must not deny and must allow (or, for endpoint policies on default, allow everything) before the request can proceed.
Three consequences follow from this:
- Same-account and cross-account requests both pass through the RCP of the account that owns the resource. This is the main difference from an SCP, which is tied to the caller's account.
- A resource-based policy that names an outside principal does not override an RCP Deny. The explicit deny wins.
- When one request crosses several of these layers, the denial may come from any of them, and the error message does not always say which.
Troubleshooting
When access is denied and your identity and resource policies look correct, work through the guardrails in this order:
- Check CloudTrail for the denied event. The
errorMessageoften says "explicit deny in a resource control policy" or "in a VPC endpoint policy." - Check whether the request used an endpoint. The CloudTrail field
vpcEndpointIdshows it. - Review the endpoint policy with
describe-vpc-endpoints. - List the RCPs and SCPs inherited by the account from root down.
- Use
aws iam simulate-principal-policyfor identity-side checks, and remember that it does not model RCPs or endpoint policies. A simulator "allowed" result therefore does not rule these two out.
Exercise
Account A (in your organization) owns a bucket whose bucket policy allows a role in account B (outside your organization) to call s3:GetObject. Your organization has an RCP that denies s3:* when aws:PrincipalOrgID does not equal your organization ID and the caller is not an AWS service. The role's identity policy in account B allows s3:GetObject. Does the request succeed? Would an SCP in your organization have changed the outcome?
Show answer
The request fails. The bucket is a supported resource in a member account, so the RCP is evaluated. The caller is not an AWS service and its organization ID does not match yours, so the RCP Deny applies. An explicit Deny beats the bucket policy Allow and the identity policy Allow. An SCP would not have helped: SCPs only govern principals in your own accounts, and the caller here is in account B outside the organization. This is the gap RCPs fill.
Exercise
An S3 gateway endpoint has the default policy. You replace it with a policy that allows only s3:GetObject on example-reports-bucket/*. A role in the VPC has an identity policy allowing s3:GetObject and s3:PutObject on that bucket. What happens when the role calls PutObject through the endpoint, and what happens when it calls PutObject from outside the VPC?
Show answer
Through the endpoint, PutObject is denied, because the endpoint policy does not allow it and the missing allow is an implicit deny, even though the identity policy permits it. From outside the VPC, the request does not use the endpoint, so the endpoint policy is not evaluated and the identity policy decides (together with any other applicable policies). To close that route, add a bucket policy Deny based on aws:SourceVpce.