i'm trying to echo out a table of several values from the aws cli. the command i'm trying to use:
aws ec2 describe-instances --query '{Name:Reservations[*].Instances[].Tags[].Value,Status:Reservations[*].Instances[].State[].Name}' --output table
the output i'm getting:
-----------------------
| DescribeInstances |
---------------------
|| Name ||
| ------------------- |
|| Agent1 ||
|| Agent2 ||
|| Agent3 ||
|| Agent4 ||
|| Agent5 ||
|| Agent6 ||
|| Agent7 ||
| ------------------- |
|| Status ||
| ------------------- |
|| running ||
|| running ||
|| stopped ||
|| running ||
|| running ||
|| stopped ||
|| running ||
| ------------------- |
how can i output it as a single table, with 2 columns?
CodePudding user response:
You can do something like this:
aws ec2 describe-instances --query 'Reservations[*].Instances[*].{Name:Tags[?Key==`Name`]|[0].Value,Status:State.Name}' --output table
The output will be something like this:
-----------------------
| DescribeInstances |
--------- -----------
| Name | Status |
--------- -----------
| first | running |
| second | running |
--------- -----------