AWS CLI output table as multi columns

Taegu KangTaegu Kang
1 min read
  • outline

When using AWS CLI output as a table, if there is a lot of depth, the columns may overlap as one.

  • resolution

Add "|[0]" to end of query.

  • example (Single Column)
aws ec2 describe-network-interfaces --query 'NetworkInterfaces[*].{PublicIP:PrivateIpAddresses[].Association.PublicIp}' --output table
---------------------------
|DescribeNetworkInterfaces|
|DescribeNetworkInterfaces|
|DescribeNetworkInterfaces|
|DescribeNetworkInterfaces|
|DescribeNetworkInterfaces|
|DescribeNetworkInterfaces|
|DescribeNetworkInterfaces|
||       PublicIP        ||
|+-----------------------+|
||  11.111.1.11          ||
|+-----------------------+|
|DescribeNetworkInterfaces|
||       PublicIP        ||
|+-----------------------+|
  • example (Multi Column)
aws ec2 describe-network-interfaces --query 'NetworkInterfaces[*].{PublicIP:PrivateIpAddresses[].Association.PublicIp|[0]}' --output table
---------------------------
|DescribeNetworkInterfaces|
+-------------------------+
|        PublicIP         |
+-------------------------+
|  None                   |
|  None                   |
|  11.111.1.1             |
|  None                   |
|  None                   |
|  None                   |
|  None                   |
|  None                   |
|  None                   |
+-------------------------+
  • reference

https://stackoverflow.com/questions/73236117/aws-cli-output-table-as-single-columns

0
Subscribe to my newsletter

Read articles from Taegu Kang directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Taegu Kang
Taegu Kang