Sub topic 3
Organizing accounts into OUs
This chapter assumes you know what an organization, its management account and its member accounts are, and that you can run basic AWS CLI commands. It covers organizational units (OUs), how the hierarchy works, and the errors people hit most often.
The hierarchy
An organization is a tree. At the top is the root, a container that holds every account. Below it you can create organizational units (OUs), which are containers for accounts and for other OUs. Accounts are the leaves of the tree.
Three rules define the model:
- An account has exactly one parent: the root or one OU.
- An OU has exactly one parent, and OUs can nest up to five levels below the root.
- Policies attached to the root or an OU apply to every account beneath it.
The third rule is the reason OUs exist. Without them you would attach a policy to each account one by one. With them you group accounts by the policies they need, then attach once.
Creating an OU and moving an account
Every OU is created under a parent, so first look up the root ID.
aws organizations list-roots
aws organizations create-organizational-unit \
--parent-id r-examplerootid111 \
--name Workloads
aws organizations move-account \
--account-id 111122223333 \
--source-parent-id r-examplerootid111 \
--destination-parent-id ou-examplerootid111-exampleouid111The root ID starts with r-. OU IDs start with ou- and include the root's identifier. A new account lands directly under the root unless you create it with a parent. That is why the example moves it afterward.
move-account needs the current parent as --source-parent-id. If you pass the wrong one, the call fails with SourceParentNotFoundException.
What changes when you move an account
Inheritance is evaluated continuously, not when you attach a policy. The moment an account moves, it stops inheriting policies from its old path and starts inheriting from the new one. Moving an account into an OU with a restrictive service control policy can break its workloads right away.
Common errors
| Symptom | Likely cause |
|---|---|
| `DuplicateOrganizationalUnitException` | A sibling OU already has that name. Names must be unique under one parent. |
| `ParentNotFoundException` | The parent ID is wrong, or you used an OU ID where the root ID is needed. |
| Policy has no effect on an account | It is attached to a different branch of the tree than the account's path. |
| Management account ignores a policy | Service control policies never restrict the management account, wherever it sits. |
| `ConstraintViolationException` on create | You exceeded the nesting depth or the OU quota. |
Deleting an OU also has a precondition: it must be empty. Move its accounts and child OUs out first.
Exercise
An account sits in OU Workloads/Prod. You move it to Workloads/Dev. Which policies does it inherit afterward, and when does the change apply?
Show answer
It inherits the policies attached to the root, to Workloads and to Dev, and it no longer inherits policies attached only to Prod. The change applies immediately when the move completes.