Sub topic 1
The organization tree: root, OUs, and accounts
Every guardrail in this tutorial is attached to a node in a tree. Before you write an SCP or an RCP, you need to know what the nodes are, how they nest, and how to list and change them. This chapter covers the structure of an AWS organization and the CLI commands that inspect and reshape it.
Prerequisites
This chapter assumes you have:
- Basic AWS account and IAM knowledge: users, roles, and identity-based policies.
- The ability to read IAM policy JSON (
Effect,Action,Resource,Condition). - The AWS CLI installed, with credentials for the organization's management account. Console users can follow along, because every CLI call below has a console equivalent.
You do not need to know anything about SCPs or RCPs yet. Later chapters define them.
The three kinds of node
An AWS organization is a hierarchy with a single top node. Three kinds of node make up the tree.
| Node | ID format | What it is | Can contain |
|---|---|---|---|
| Root | `r-` followed by 4 to 32 lowercase letters or digits | The parent container for everything in the organization | OUs and accounts |
| Organizational unit (OU) | `ou-` followed by the root suffix, a hyphen, and 8 more characters | A named group of accounts or other OUs | OUs and accounts |
| Account | 12-digit number | An AWS account that holds actual resources | Nothing in the tree. It holds resources, not nodes |
Policies attach to any of these three. Accounts are the leaves, so they are the only nodes that run workloads, and they are the only place where a principal or a resource lives.
The root
The root is created automatically when you create an organization. It is not an account and it holds no resources. It is only the attachment point at the top of the tree. An organization has exactly one root. You cannot rename it or delete it.
Organizational units
An OU groups accounts so that you can manage them together. Typical designs group by environment (Prod, Dev, Sandbox), by workload, or by compliance requirement (for example, a Regulated OU).
OUs follow these rules:
- An OU can contain accounts and other OUs.
- An OU has exactly one parent: either the root or another OU.
- OUs can be nested up to five levels deep below the root.
- An OU name must be unique among its siblings, not across the whole organization.
Accounts
Each account is in exactly one place in the tree: directly under the root or under one OU. Moving an account changes which policies apply to it immediately, because the account's effective policies are determined by the path from the root down to it. The next chapters cover that in detail.
There are two account roles:
- The management account creates the organization. It pays the bills for all accounts, and it is the only account that can perform several sensitive tasks, such as closing the organization.
- Member accounts are every other account.
The management account sits in the tree like any other account, but SCPs do not restrict it. This is the main reason to keep workloads out of it.
All features versus consolidated billing
An organization runs in one of two feature sets.
- Consolidated billing only gives you a single bill and nothing else.
- All features adds centralized management: authorization policies (SCPs and RCPs), tag policies, integration with other AWS services, and more.
SCPs and RCPs only work when the organization has all features enabled. Organizations created today use all features by default. An older organization may still be on consolidated billing only. To check, run:
aws organizations describe-organization \
--query "Organization.{Id:Id,Master:MasterAccountId,FeatureSet:FeatureSet}"If FeatureSet is CONSOLIDATED_BILLING, you must enable all features first. That process sends an invitation to each member account, and each account owner must approve it.
Inspecting the tree with the CLI
Run these commands from the management account, or from a delegated administrator for a supported service. Most organization APIs are available only in the management account unless a command is explicitly delegable. The Organizations API endpoint is global, so you do not pick a Region for it.
Start with the root. You need its ID for nearly every later command:
aws organizations list-roots \
--query "Roots[0].Id" --output textNext, list the OUs directly under a parent. A parent is a root ID or an OU ID:
aws organizations list-organizational-units-for-parent \
--parent-id r-examplerootid \
--query "OrganizationalUnits[].{Id:Id,Name:Name}" \
--output tableList the accounts directly under a parent:
aws organizations list-accounts-for-parent \
--parent-id ou-exam-ple12345 \
--query "Accounts[].{Id:Id,Name:Name,Status:Status}" \
--output tableBoth commands list only direct children. They do not recurse, so to see the whole tree you call them once per OU. To find where a single account lives, ask for its parents:
aws organizations list-parents --child-id 111122223333list-parents returns one entry because an account or OU has exactly one parent.
Building and reshaping the tree
Create an OU under the root or under another OU:
aws organizations create-organizational-unit \
--parent-id r-examplerootid \
--name WorkloadsThe response contains the new OU's ID. Use it to nest another OU or to move accounts:
aws organizations create-organizational-unit \
--parent-id ou-exam-ple12345 \
--name ProdMove an account from one parent to another:
aws organizations move-account \
--account-id 111122223333 \
--source-parent-id r-examplerootid \
--destination-parent-id ou-exam-ple67890You must give the correct source parent, or the call fails. Use list-parents first when you are unsure.
Remove an OU with delete-organizational-unit. An OU must be empty before it can be deleted: it must contain no accounts and no child OUs.
aws organizations delete-organizational-unit \
--organizational-unit-id ou-exam-ple67890Common errors
| Error | Likely cause |
|---|---|
| `AccessDeniedException` | The caller is not in the management account or a delegated administrator account, or the IAM policy does not allow the call |
| `AWSOrganizationsNotInUseException` | The account is not part of an organization |
| `DuplicateOrganizationalUnitException` | A sibling OU already has that name |
| `ConstraintViolationException` | A limit was reached, such as nesting depth, or the OU is not empty on delete |
| `SourceParentNotFoundException` | The `--source-parent-id` in `move-account` does not match the account's real parent |
| `ParentNotFoundException` | The parent ID does not exist, often from a typo or a pasted ID from another organization |
Why the shape of the tree matters
Policies flow downward. A policy attached to an OU applies to every account in that OU and in every OU beneath it. This has direct design consequences:
- Group by the policy you want to apply, not by org chart. If all production accounts need the same guardrails, put them under one
ProdOU. Attach once, and every current and future account is covered. - Keep the tree shallow. Deep trees are harder to reason about. When a request is denied, you have to inspect every node on the path from the root to the account. Two or three levels cover most designs, and the limit of five is a ceiling, not a target.
- Plan for moving accounts. Moving an account to a different OU changes its effective permissions at once. Treat
move-accountas a permission change and review it the way you review an IAM change. - Keep the management account under the root and mostly empty. Put workloads in member accounts, where guardrails apply to them.
- Use a test OU. A small OU with a few non-critical accounts gives you a safe place to attach a new policy first. The rollout chapter returns to this idea.
Where we go next
You now have the vocabulary and the commands: one root, OUs nested up to five levels, and each account in exactly one place. The next chapter covers the authorization policy types that you can attach to these nodes and how to enable them on the root.
Exercise
Your organization has the root, an OU named Workloads, and under it an OU named Prod that contains the account 111122223333. You run aws organizations move-account --account-id 111122223333 --source-parent-id r-examplerootid --destination-parent-id ou-exam-ple67890 and get SourceParentNotFoundException. What happened, and what command would you run to find the correct value?
Show answer
The --source-parent-id does not match the account's current parent. The account is under the Prod OU, not directly under the root. Run aws organizations list-parents --child-id 111122223333 to get the actual parent ID, then repeat move-account with that value as the source parent.
Exercise
A teammate proposes creating one OU per team, 40 OUs in total, and nesting them six levels deep to mirror the company's reporting lines. Give two reasons this design is a poor fit for guardrails, and say which constraint it breaks outright.
Show answer
It breaks the limit of five OU levels below the root, so it cannot be created as described. Beyond that, reporting lines do not match policy needs: accounts that need the same guardrails end up scattered across many OUs, so you attach the same policy repeatedly. Deep paths also make it harder to work out which policies apply when a request is denied. A shallow tree grouped by environment or compliance requirement is easier to manage.