0

We have multiple OU's in our AWS organisation.

We use AWS cli to create new AWS organisation members. For eg.

aws organizations create-account --email test@example.com --account-name "testaccount"

Everytime a new member account is created, it is added under root and not in any OU.

We want to add new member account in a particular OU. We can move the new member accounts manually through cli or console to any OU but we want to specify it at the time of account creation itself.

It will be really helpful if someone can point me into the right direction.

Update:

I'm trying to automate moving of new member accounts from root to a particular OU. This is what I've done, running these commands from a ps1 file. I'm not being able to pass $AccId variable in the move command. Any suggestions?

aws organizations create-account --email test@example.com --account-name test
$Id = aws organizations list-create-account-status --states IN_PROGRESS --query 'CreateAccountStatuses[*].Id' --output text
$AccId = aws organizations describe-create-account-status --create-account-request-id $Id --query 'CreateAccountStatus.AccountId' --output text
aws organizations move-account --account-id $AccId --source-parent-id r-0000 --destination-parent-id ou-0000-000000
Axel
  • 323
  • 1
  • 6
  • 17

1 Answers1

0

My read of the documentation says it's currently not possible. As you already do you have to use move account:

aws organizations move-account --account-id 333333333333 --source-parent-id r-examplerootid111 --destination-parent-id ou-examplerootid111-exampleouid111
Tim
  • 30,383
  • 6
  • 47
  • 77