using aws-cli with a human-oriented output format
If you keep creating AWS accounts for every project, as I do, then you will build up a large inventory of accounts. Occasionally, you might want to get a list of all of the accounts for easy review.
The following simple aws-cli command pipeline:
- filters to just the active (non-deleted) AWS accounts
- sorts by account create/join time
and outputs the following values in nicely aligned columns:
- AWS account id
- account email address
- account name
Here’s the command pipeline (contains some bash-ism):
aws organizations list-accounts \
--output text \
--query 'Accounts[?Status==`ACTIVE`][Status,JoinedTimestamp,Id,Email,Name]' |
sort |
cut -f2- |
column -t -n -e -s$'\cI'
Here is a sample of what the output might look like: