aws:list_accounts_in_org
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
aws:list_accounts_in_org [23/06/2025 11:34] – created andrew | aws:list_accounts_in_org [01/07/2025 13:37] (current) – andrew | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | |||
- | |||
list_accounts_in_organisations.sh | list_accounts_in_organisations.sh | ||
- | |||
<code bash> | <code bash> | ||
#!/bin/bash | #!/bin/bash | ||
Line 12: | Line 9: | ||
# This gives a text output, the default is json, --output table is also valid. | # This gives a text output, the default is json, --output table is also valid. | ||
- | disable_check]$ aws organizations list-accounts --query ' | + | aws organizations list-accounts --query ' |
+ | |||
+ | # Using jq to parse the JSON | ||
+ | aws organizations list-accounts | jq -r ' | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | Iterates over the accounts in an organisation. | ||
+ | < | ||
+ | # | ||
+ | |||
+ | ACCOUNTS_RAW=$(aws organizations list-accounts --query ' | ||
+ | ACCOUNTS=" | ||
+ | |||
+ | echo " | ||
+ | echo " | ||
+ | |||
+ | for ACCOUNT in $ACCOUNTS | ||
+ | do | ||
+ | echo " | ||
+ | echo "do some work on each account" | ||
+ | done | ||
</ | </ | ||
aws/list_accounts_in_org.1750678487.txt.gz · Last modified: by andrew