Lesson 3 of 6 Identity Federation and Cross-Account Access

Designing Organisation-Wide Data Perimeters

This lesson explains how a data perimeter adds organisation-wide guardrails so that data flows only between trusted identities, trusted resources and expected networks, regardless of how any one policy is written.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish the identity, resource and network perimeters.
  • Choose where each perimeter control is applied.
  • Design exceptions for AWS services and partners.
  • Describe how a perimeter is rolled out safely.

The three perimeters

A data perimeter is a set of guardrails that keeps data within trusted boundaries, built from three perimeters. The identity perimeter ensures that only trusted identities access your resources. It is implemented with resource policies and RCPs that require aws:PrincipalOrgID to be your organisation. The resource perimeter ensures your identities access only trusted resources, which stops an insider or compromised role from copying data to an attacker's bucket. It is implemented with SCPs and VPC endpoint policies that check aws:ResourceOrgID. The network perimeter ensures access comes only from expected networks, using aws:SourceVpc, aws:SourceVpce and aws:SourceIp. The following table summarises the perimeters.

PerimeterEnsuresImplemented with
IdentityOnly trusted identities access your resourcesResource policies and RCPs with aws:PrincipalOrgID
ResourceYour identities access only trusted resources, stopping copies to an attacker's bucketSCPs and VPC endpoint policies with aws:ResourceOrgID
NetworkAccess only from expected networksaws:SourceVpc, aws:SourceVpce, aws:SourceIp
Match the pairs

Building a data perimeter

Exam skills 2.1.4

Match each perimeter statement with the control and condition key that implement it.

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

Where each control is applied

The perimeters are enforced at three points, and a complete design uses all of them because each covers a gap in the others. Resource control policies apply the identity and network perimeters to supported resources, such as S3 buckets, KMS keys, SQS queues, STS role assumption and Secrets Manager secrets, in every member account, whoever the caller is. A bucket policy written carelessly by one team therefore cannot open the bucket to an outside account.

Service control policies apply the resource and network perimeters to the organisation's own principals, wherever the resource is, which stops a compromised role from writing to a bucket in an attacker's account. VPC endpoint policies apply the identity and resource perimeters to traffic leaving a VPC through an endpoint, which stops a compromised instance that uses credentials from another organisation from reaching that organisation's buckets through your network.

The following diagram shows the request that each of three data perimeter controls blocks.

Where each data perimeter control applies. A resource control policy that requires aws:PrincipalOrgID stops identities outside the organisation reaching your resources. A service control policy that requires aws:ResourceOrgID stops your own principals copying data to an attacker's bucket. A VPC endpoint policy stops a compromised instance using another organisation's credentials to reach that organisation's buckets through your network.
Each control closes a path that the other two cannot see, which is why a complete perimeter uses all three.

Exceptions that must be designed in

A perimeter that blocks everything outside the organisation also blocks legitimate access, so exceptions are part of the design rather than afterthoughts. AWS services often act on the customer's behalf, for example CloudTrail writing logs to a bucket or a service reading from a key; the conditions aws:PrincipalIsAWSService and aws:ViaAWSService recognise such requests, and without them service integrations fail.

Some AWS services read resources owned by AWS, such as buckets that host agent installers or public datasets, which the resource perimeter must allow explicitly. Trusted third parties, such as a monitoring vendor whose role is in another organisation, need named exceptions in the identity perimeter. Finally, conditions should use the IfExists operators where a request may legitimately lack the condition key, so that, for example, a network condition does not deny requests that do not come through a VPC at all when that is intended.

Rolling out a perimeter safely

Data perimeter policies must be introduced carefully to avoid disrupting legitimate access. The recommended procedure is as follows.

  1. Analyse current access

    Use CloudTrail and IAM Access Analyzer to find legitimate external access.

  2. Write and stage the policies

    Write the policies with the required exceptions and attach them to a Policy Staging OU.

  3. Move accounts in gradually

    Start with sandbox and non-production OUs, and watch for access denied errors.

  4. Attach at the root

    Attach the policies at the root once the exceptions are complete, and review them whenever a new integration is added.

Put in order

Rolling out a perimeter

Exam skills 2.1.4

Put the steps for rolling out a data perimeter control in order.

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

A resource perimeter with an SCP

Employees must not be able to copy data to S3 buckets outside the organisation, a common exfiltration path. That is a resource perimeter, enforced on the organisation's own principals with an SCP:

{
  "Sid": "EnforceResourcePerimeter",
  "Effect": "Deny",
  "Action": ["s3:PutObject", "s3:GetObject", "s3:ListBucket"],
  "Resource": "*",
  "Condition": {
    "StringNotEqualsIfExists": { "aws:ResourceOrgID": "o-a1b2c3d4e5" },
    "BoolIfExists": { "aws:PrincipalIsAWSService": "false" }
  }
}

Some AWS services read from AWS-owned buckets on your behalf (for example when installing agents or reading public datasets), so production policies list the necessary exceptions. The same condition in the S3 gateway endpoint policy of each VPC adds a network-level layer: even credentials from another organisation used on a compromised instance cannot reach an external bucket through the endpoint.

The complementary identity perimeter is an RCP with aws:PrincipalOrgID. If it covers sts:AssumeRole, trusted third parties whose roles sit outside the organisation, such as a monitoring vendor, must be added as explicit exceptions. Perimeters and legitimate integrations have to be designed together, and new policies are attached to a Policy Staging OU before the root.

Check yourself

Which condition key limits access to principals that belong to your organisation?

Show answer

aws:PrincipalOrgID, used in resource-based policies or a resource control policy.

Exam Tips

Remember for the exam

  • To accept requests only from your organisation, use aws:PrincipalOrgID in resource policies or RCPs.
  • To stop identities copying data to buckets outside the organisation, use an SCP or endpoint policy with aws:ResourceOrgID.
  • To allow access only through your VPCs, use aws:SourceVpce or aws:SourceVpc conditions.
  • Exempt AWS services acting on your behalf with aws:PrincipalIsAWSService and aws:ViaAWSService.
  • Roll perimeter policies out through a staging OU, because missing exceptions break legitimate access.