Building Data Perimeters with SCPs, RCPs and Endpoint Policies
This lesson explains how a data perimeter, a set of preventive guardrails ensuring that only trusted identities access trusted resources from expected networks, is built, and which policy type and condition key suit each direction.
Learning outcomes
After completing this lesson, you will be able to:
- Distinguish the identity, resource and network perimeters.
- Describe typical perimeter policies with aws:PrincipalOrgID and aws:ResourceOrgID.
- Explain how service principals are handled without opening a confused deputy risk.
- Describe how perimeter policies are rolled out without breaking legitimate access.
Three perimeters, six combinations
A data perimeter rests on three questions. The identity perimeter asks whether the caller is one of ours. It is applied with RCPs, resource policies and VPC endpoint policies, using aws:PrincipalOrgID, with aws:PrincipalIsAWSService to allow AWS services that act on your behalf. The resource perimeter asks whether the resource is one of ours. It is applied with SCPs and VPC endpoint policies using aws:ResourceOrgID or aws:ResourceAccount, which stops data from being copied to buckets outside the organisation.
The network perimeter asks whether the request comes from our networks. It is applied with SCPs, RCPs and resource policies using aws:SourceIp, aws:SourceVpc and aws:SourceVpce, with aws:ViaAWSService to exempt requests that AWS services make on a principal's behalf. The following table summarises the perimeters.
| Perimeter | Question | Applied with | Key condition keys |
|---|---|---|---|
| Identity | Is the caller one of ours? | RCPs, resource policies, VPC endpoint policies | aws:PrincipalOrgID, aws:PrincipalIsAWSService |
| Resource | Is the resource one of ours? | SCPs, VPC endpoint policies | aws:ResourceOrgID, aws:ResourceAccount |
| Network | Is the request from our networks? | SCPs, RCPs, resource policies | aws:SourceIp, aws:SourceVpc, aws:SourceVpce, aws:ViaAWSService |
Each perimeter can be enforced on the identity side (what our principals may reach) and on the resource side (who may reach our resources). Mature designs implement the combinations that matter for their data, rather than all six at once.
Perimeters and condition keys
Typical policies
A data perimeter is implemented through a small number of typical policies. The following list describes them.
- RCP, identity perimeter: deny S3, KMS, SQS, STS and Secrets Manager access when
aws:PrincipalOrgIDis not ours, unlessaws:PrincipalIsAWSServiceis true. A bucket policy mistakenly granting another account then has no effect. - SCP, resource perimeter: deny
s3:*on resources whoseaws:ResourceOrgIDis not ours, so a stolen role cannot copy data to an attacker's bucket. Exceptions are needed for AWS-owned resources that services read, such as public datasets or package repositories. - SCP or RCP, network perimeter: deny when the request comes from neither the corporate IP ranges nor our VPCs, unless an AWS service makes it on the caller's behalf (
aws:ViaAWSService). Credentials stolen from an instance then fail from the internet. - VPC endpoint policy: allow only principals and resources in our organisation through the endpoint, closing the path from inside the VPC to outside accounts.
The following diagram shows where an SCP-based resource perimeter stops a developer copying data to a bucket outside the organisation.

A resource perimeter that does nothing
Service principals and the confused deputy
When an AWS service accesses a resource on your behalf, the caller is a service principal, not an identity in your organisation, so aws:PrincipalOrgID does not apply. Resource policies that allow a service principal should restrict it with aws:SourceArn, aws:SourceAccount or aws:SourceOrgID, so the service acting for another customer cannot be tricked into using your resource.
Rolling out without breaking things
Data perimeter policies must be introduced carefully to avoid disrupting legitimate access. The recommended procedure is as follows.
-
Find current access
Use IAM Access Analyzer and CloudTrail queries to find calls whose principal or resource account is outside the organisation.
-
Write the policies
Include explicit exceptions for partners, AWS service accounts and third-party tools. AWS publishes example policies for every perimeter in its data perimeter policy examples repository; start from those.
-
Roll out gradually
Attach to a test OU, then to OUs in order of risk, watching for AccessDenied errors in CloudTrail.
Rolling out a data perimeter
A company worries that a developer with legitimate read access to sensitive S3 data could copy it to a bucket in a personal AWS account. The control must apply to all accounts and must not depend on each team writing correct policies.
This is a resource perimeter on the identity side: our principals must not write to resources outside the organisation. An SCP denying s3:PutObject (and similar actions) when aws:ResourceOrgID differs from the organisation's ID, attached at the root, enforces it centrally. An RCP would not help, because RCPs protect our resources, and the attacker's bucket is not ours.
Which condition key enforces the resource perimeter?
Show answer
aws:ResourceOrgID, in SCPs and VPC endpoint policies.
Exam Tips
Remember for the exam
- Identity perimeter: aws:PrincipalOrgID in RCPs and resource policies.
- Resource perimeter: aws:ResourceOrgID in SCPs and VPC endpoint policies.
- Network perimeter: aws:SourceIp, aws:SourceVpc, aws:SourceVpce, with aws:ViaAWSService exceptions.
- SCPs stop our principals reaching outside resources; RCPs stop outside principals reaching our resources.
- Restrict service principals with aws:SourceArn, aws:SourceAccount or aws:SourceOrgID.
- Roll out perimeters gradually after analysing current cross-boundary access.