Lesson 6 of 6 AWS Organizations and AWS Control Tower

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.

PerimeterQuestionApplied withKey condition keys
IdentityIs the caller one of ours?RCPs, resource policies, VPC endpoint policiesaws:PrincipalOrgID, aws:PrincipalIsAWSService
ResourceIs the resource one of ours?SCPs, VPC endpoint policiesaws:ResourceOrgID, aws:ResourceAccount
NetworkIs the request from our networks?SCPs, RCPs, resource policiesaws: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.

Match the pairs

Perimeters and condition keys

Exam skills 6.1.3

Match each perimeter question with its key condition keys.

Log in to try this activity Interactive activities are free with an account.

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:PrincipalOrgID is not ours, unless aws:PrincipalIsAWSService is true. A bucket policy mistakenly granting another account then has no effect.
  • SCP, resource perimeter: deny s3:* on resources whose aws:ResourceOrgID is 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 enforced on the identity side. An SCP at the root denies s3:PutObject and similar actions when aws:ResourceOrgID is not the organisation's, so a developer cannot copy sensitive data to a personal account's bucket. An RCP would not help: RCPs protect the organisation's resources, and that bucket is not one of them.
RCP stands for resource control policy.
Spot the bug

A resource perimeter that does nothing

Exam skills 6.1.3

Find the lines that stop this SCP from preventing copies to buckets outside the organisation.

Log in to try this activity Interactive activities are free with an account.

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.

  1. Find current access

    Use IAM Access Analyzer and CloudTrail queries to find calls whose principal or resource account is outside the organisation.

  2. 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.

  3. Roll out gradually

    Attach to a test OU, then to OUs in order of risk, watching for AccessDenied errors in CloudTrail.

Put in order

Rolling out a data perimeter

Exam skills 6.1.3

Arrange the steps for introducing data perimeter policies safely.

Log in to try this activity Interactive activities are free with an account.
Worked example

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.

Check yourself

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.