aws:orgs
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| aws:orgs [18/09/2025 14:11] – andrew | aws:orgs [25/09/2025 14:51] (current) – removed andrew | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Organisations ====== | ||
| - | |||
| - | Get Root ID | ||
| - | |||
| - | With text output:- | ||
| - | OrgRoot=$(aws organizations list-roots --query ' | ||
| - | |||
| - | Using JQ:- | ||
| - | OrgToot=$(aws organizations list-roots | jq -r .Roots.[0].Id) | ||
| - | |||
| - | |||
| - | ===== Get a list of OU's in an organisation ===== | ||
| - | |||
| - | |||
| - | OU_IDs=$(aws organizations describe-organization --query ' | ||
| - | |||
| - | |||
| - | |||
| - | <code bash> | ||
| - | #!/bin/bash | ||
| - | # Get the root of an Org and find the subordinate OUs in it. | ||
| - | |||
| - | ROOT_ID=$(aws organizations list-roots | jq -r .Roots.[0].Id) | ||
| - | printf "Root ID:- ${ROOT_ID}\n" | ||
| - | |||
| - | OUS=$(aws organizations list-organizational-units-for-parent --parent-id " | ||
| - | printf "OUs:- ${OUS}\n\n" | ||
| - | </ | ||
| - | |||
| - | |||
| - | Seearch for an OU by name:- | ||
| - | <code bash> | ||
| - | SpecificOU=$(aws organizations list-organizational-units-for-parent \ | ||
| - | --parent-id $RootId \ | ||
| - | --query ' | ||
| - | </ | ||
| - | |||
| - | |||
| - | ===== List Accounts in OU / Org ===== | ||
| - | |||
| - | <code bash> | ||
| - | ACCOUNTS_RAW=$(aws organizations list-accounts --query ' | ||
| - | ACCOUNTS=" | ||
| - | |||
| - | echo " | ||
| - | echo " | ||
| - | |||
| - | for ACCOUNT in $ACCOUNTS | ||
| - | do | ||
| - | echo " | ||
| - | echo "do some work on each account" | ||
| - | done | ||
| - | </ | ||
| - | |||
| - | |||
| - | |||
| - | |||
| - | |||
| - | ===== Truncate account number ===== | ||
| - | |||
| - | Sometimes you may want to point to an account, but not reveal the full account number, this code will truncate your account to a specified length. | ||
| - | |||
| - | <code python> | ||
| - | $ cat truncate.py | ||
| - | # | ||
| - | |||
| - | account = ' | ||
| - | removechar = 6 | ||
| - | |||
| - | result1 = account[removechar: | ||
| - | result2 = account[removechar: | ||
| - | print(result1, | ||
| - | |||
| - | $ ./ | ||
| - | 784321 784321 | ||
| - | |||
| - | </ | ||
| - | |||
| - | |||
| - | |||
aws/orgs.1758204695.txt.gz · Last modified: by andrew
