Using the AWS CLI, how do I output a list of all the accounts with just Account Names and Account Numbers?
The below command outputs Account Names and Numbers along with other values, how do I filter this?
aws organizations list-accounts
The below command outputs Account names and Account numbers in a tabular format -
aws organizations list-accounts --query 'Accounts[*].[Name, Id]' --output table
Output:
----------------------------------------------------------------------
| ListAccounts |
+----------------------------------------------------+---------------+
| alphabet-finance-dev | 80XX00000001 |
| alphabet-security-prd | 80XX43500061 |
| alphanet-devops-tst | 50XX00000046 |
| ................ | ............ |
+----------------------------------------------------+---------------+
For output in text -
aws organizations list-accounts --query 'Accounts[*].[Name, Id]' --output text
For output in JSON -
aws organizations list-accounts --query 'Accounts[*].[Name, Id]' --output json
For output in YAML -
aws organizations list-accounts --query 'Accounts[*].[Name, Id]' --output yaml