Understanding Aws Cli Output Text


Modified:   May 16, 2022
Published:   November 12, 2021

Tags:
Ref: https://web.archive.org/web/20211112032254/https://carriagereturn.nl/aws/cli/scripting/2018/07/17/aws-cli-output.html

–output=text will print everything within innermost [] brackets on single line..

To see it in action see the difference between

1
aws iam list-users --query Users[*].[UserName]

vs

1
aws iam list-users --query [Users[*].UserName]

For nested list object, instead of [*] use [0](individual item) for single line output. Like here for CacheClusters[].CacheNodes

To see it in action see the difference between

1
aws elasticache describe-cache-clusters   --show-cache-node-info --query CacheClusters[].[CacheClusterId,CacheNodes[0].Endpoint.Address] --output table

vs

1
aws elasticache describe-cache-clusters   --show-cache-node-info --query CacheClusters[].[CacheClusterId,CacheNodes[].Endpoint.Address] --output table


Let me know if you have any questions or comments.
It will help me to improve/learn.


< Older   Further Reading   Newer >