Sub topic 5
Creating Accounts and Bringing In Existing Ones
This chapter assumes you know the AWS CLI and IAM roles, and that you have already created an organization with at least one OU. There are two ways to add an account to an organization. You can create a new one, or you can invite an account that already exists.
Creating a new account
A new member account needs a unique email address and a name. Organizations creates the account, places it under the root, and creates an administrative role inside it. That role is called OrganizationAccountAccessRole by default.
aws organizations create-account \
--email [email protected] \
--account-name prod-app1The call returns immediately with a request ID and a state of IN_PROGRESS. Creation is asynchronous. Poll for the result:
aws organizations describe-create-account-status \
--create-account-request-id car-examplerequestid111When the state is SUCCEEDED, the output includes the 12-digit account ID. A new account lands directly under the root, so move it into an OU:
aws organizations move-account \
--account-id 111122223333 \
--source-parent-id r-examplerootid111 \
--destination-parent-id ou-examplerootid111-exampleouid111You can pass --role-name to create-account to choose a different name for the administrative role. You cannot change it afterwards.
Inviting an existing account
An account that already runs workloads can join through an invitation. The management account sends it:
aws organizations invite-account-to-organization \
--target Id=444455556666,Type=ACCOUNTThe owner of the invited account accepts it from that account, in the console or with aws organizations accept-handshake. An invitation is a handshake object, and it expires if nobody accepts it.
An invited account does not get OrganizationAccountAccessRole. Create that role yourself in the account, with a trust policy that names the management account. Without it you have no administrative path in from the management account.
Common errors
- Email already in use. Every account needs a globally unique root email address. Use a plus-addressed alias or a distribution list, such as
[email protected]. - Account quota reached. New organizations start with a low default account limit. Request an increase before you automate bulk creation.
- Invited account cannot join. The account must have a valid payment method and must not already belong to another organization. It has to leave its old organization first.
- Feature set mismatch. You can only attach SCPs and use most integrations when the organization has all features enabled. An organization with only consolidated billing cannot do this.
Exercise
You invited a standalone account and its owner accepted. From the management account, sts assume-role into OrganizationAccountAccessRole fails. What is the most likely cause, and how do you fix it?
Show answer
Invited accounts do not get OrganizationAccountAccessRole automatically, so the role does not exist. Create it in the invited account with a trust policy that allows the management account, and attach an administrative permissions policy. Then retry the assume-role call.