Sub topic 4
Designing an OU structure that lasts
An organizational unit (OU) is a container for accounts and other OUs. Creating one takes a single command. Designing a structure that still works after three years and two reorganizations takes more thought. This chapter covers how to decide what an OU is for, which layouts hold up, and which mistakes are expensive to undo.
This chapter assumes you have read the previous chapters on Organizations and OUs. You should know that an organization has one root, that OUs nest up to five levels deep below the root, and that each account sits in exactly one OU or directly under the root.
What an OU is for
An OU exists to attach policy to a group of accounts. Policies attached to the root or to an OU apply to every account below it. This is the main reason to create an OU, and it should drive the design.
A useful test for any proposed OU: what policy or administrative difference does this OU express? If the answer is "none, it just mirrors the org chart," the OU probably doesn't belong.
OUs are not a reporting tool. Cost reporting, ownership and compliance scope are better handled with account tags, cost allocation tags and account naming. Those can change without moving accounts.
Design principles
Group by policy need, not by org chart
Company org charts change often. Policy needs change slowly. If you create OUs named after departments, each reorganization forces account moves, and every move changes which policies apply to the account.
Group by what the accounts need from guardrails:
- Production workloads need strict controls, such as blocking deletion of logs.
- Development and sandbox accounts need looser controls, such as broader service access, but tighter cost limits.
- Security and infrastructure accounts need protection from workload teams.
Keep the hierarchy shallow
The limit is five levels, but most organizations need two or three. SCP evaluation requires an allow at every level between the root and the account. Deep trees make it hard to answer "why was this action denied?" Each additional level is another place a policy can be attached.
Separate environments from workloads carefully
There are two common ways to combine workload and environment:
| Layout | Example | Strength | Weakness |
|---|---|---|---|
| Environment first | `Prod/payments`, `Dev/payments` | One OU holds one set of guardrails per environment | Teams span several OUs |
| Workload first | `Payments/prod`, `Payments/dev` | Team-specific policy is easy | Environment guardrails are repeated per team |
Most organizations start environment first. Production versus non-production is the difference that nearly every guardrail cares about. Add workload-specific OUs only when a workload has its own policy needs, such as a regulated payments system.
Isolate foundational accounts
Accounts that run the organization itself should sit apart from workloads. This lets you apply stricter policy to them and avoids accidentally applying workload guardrails to them. Typical foundational accounts:
- Log archive
- Security tooling or audit
- Shared networking
- Shared services such as CI/CD or a central artifact registry
Keep the management account out of the way
The management account is not affected by SCPs. SCPs never restrict it, whatever OU it sits in. Run as little as possible there: no workloads, and only the people who administer the organization should have access. Use delegated administrators for services where possible, as later chapters describe.
A reference structure
AWS's published guidance on multi-account design uses a set of OUs close to the following. Treat it as a starting point and remove what you don't need.
What each OU is for:
| OU | Contents | Typical policy |
|---|---|---|
| Security | Log archive, audit and security tooling accounts | Deny changes to logging and security services; very few human users |
| Infrastructure | Network, shared services | Deny actions outside the approved set of Regions and services |
| Workloads/Prod | Production application accounts | Deny leaving the organization, deny disabling logging and guard services |
| Workloads/Non-prod | Dev and test accounts | Same baseline as Prod, with cost guardrails |
| Sandbox | Individual experimentation | Limited services, budget limits, restricted networking |
| Suspended | Closed or quarantined accounts | Deny all actions |
Why a Suspended OU helps
When you close an account, it is not deleted at once. It enters a suspended state and AWS keeps it for a period of days before permanent closure. During that time it is still a member of your organization. Moving these accounts into a dedicated OU with a deny-everything SCP makes sure nobody can use them in the meantime. It also gives auditors a clear place to see retired accounts.
The same OU works for accounts you suspect are compromised: move the account in, and the SCP blocks all activity from the account's principals while you investigate.
Putting the design into practice
Create the OUs with the AWS CLI. First look up the root ID, then create each OU under it.
ROOT_ID=$(aws organizations list-roots --query 'Roots[0].Id' --output text)
for name in Security Infrastructure Workloads Sandbox Suspended; do
aws organizations create-organizational-unit \
--parent-id "$ROOT_ID" \
--name "$name"
done
WORKLOADS_ID=$(aws organizations list-organizational-units-for-parent \
--parent-id "$ROOT_ID" \
--query "OrganizationalUnits[?Name=='Workloads'].Id" \
--output text)
for name in Prod Non-prod; do
aws organizations create-organizational-unit \
--parent-id "$WORKLOADS_ID" \
--name "$name"
doneFor a structure you intend to keep, define it in code. The Terraform below declares the same two levels, so changes go through review.
locals {
top_level_ous = ["Security", "Infrastructure", "Workloads", "Sandbox", "Suspended"]
workload_ous = ["Prod", "Non-prod"]
}
resource "aws_organizations_organizational_unit" "top" {
for_each = toset(local.top_level_ous)
name = each.key
parent_id = aws_organizations_organization.org.roots[0].id
}
resource "aws_organizations_organizational_unit" "workload" {
for_each = toset(local.workload_ous)
name = each.key
parent_id = aws_organizations_organizational_unit.top["Workloads"].id
}This assumes the aws_organizations_organization.org resource from the earlier Terraform example.
Edge cases and common mistakes
- Renaming and moving cost little, but moving changes policy. Renaming an OU has no effect on policy. Moving an account to a different OU changes its inherited SCPs immediately. Test the effect before you move a production account.
- Moving an OU moves everything inside it. Every account under that OU inherits a new set of policies from its new parent. Review the new parent's policies first.
- Policy attached at the root hits everything. A mistake in a root-level SCP affects every member account. Attach new policies to a test OU first, and promote them upward only after they work.
- Don't put accounts directly under the root. An account directly under the root inherits only root-level policy, and nothing marks its purpose. Keep every account in an OU, even if the OU has one account.
- One OU per account is a smell. If every OU holds one account and carries its own unique policy, you have lost the benefit of inheritance. Merge them, or use account-level exceptions through conditions.
- Don't encode too much in the hierarchy. Region, cost center, team, compliance scope and environment cannot all be levels. Choose the one or two that drive policy. Use tags for the rest.
- Limits apply. An organization has default quotas on the number of accounts and on SCPs per target. An SCP document is limited to 5,120 characters, and at most five SCPs can be attached to a single root, OU or account. Careful design keeps you under these limits: put broad policy high, narrow policy low, and avoid attaching many small policies to one target.
Testing a design
Before you commit to a structure, walk a few real accounts through it:
- Pick an account for each type you run, such as production app, dev app, log archive and sandbox.
- For each, list the SCPs it would inherit from the root down to its OU.
- Check that no account needs an exception that its OU can't give.
- Add a hypothetical new account, such as a new regulated workload. Check that it has an obvious home.
If a case needs a new OU level each time, the dimension you chose is wrong.
Exercise
A company creates OUs named Marketing, Finance and Engineering to mirror its departments. Six months later Finance is merged into Operations, and two Finance accounts must move to Engineering. Give two reasons this design is fragile, and describe a better primary grouping.
Show answer
First, department structure changes more often than policy needs, so every reorganization forces account moves. Second, moving an account changes the SCPs it inherits immediately, so a reorganization can silently remove permissions from running workloads. A better grouping is by policy need, for example Security, Infrastructure, Workloads (split into Prod and Non-prod), Sandbox and Suspended. Track department ownership with account tags and cost allocation tags instead.
Exercise
Why is it a bad idea to attach an untested SCP directly to the root, and what should you do instead?
Show answer
A root-level SCP applies to every member account, so a mistake can break the whole organization at once. Attach the policy to a test OU that holds non-critical accounts, confirm that it behaves as expected, and then attach it at a higher level or to the target OUs.