2016-08-01 8 views
1

Wie kann ich Liste ipaddress und Tag-Namen aws cli aws ec2 describe-instances --query "Reservations[*].Instances[*].PrivateIpAddress[*]" --output tableAWS Cli Liste IPAddess und Namensschild

Gibt mir die Liste der ipaddess aber ich brauche IP-Adresse und Namensschild verwenden.

Bitte helfen.

+0

Sie sollten die Beispiele auf [jmespath.org] (http://jmespath.org/examples.html) überprüfen. –

Antwort

1

können Sie

aws ec2 describe-instances \ 
--query "Reservations[*].Instances[*].{privateIP:PrivateIpAddress, tags:Tags[*]}" 

Folgendes tun können Sie die table Ausgang hinzufügen, wenn nötig, aber die Sicht ist nicht so gut, wenn man mehrere Tags haben

aws ec2 describe-instances \ 
--query "Reservations[*].Instances[*].{privateIP:PrivateIpAddress, tags:Tags[*]}" \ 
--output table 

der Ausgang wird

---------------------------- 
|  DescribeInstances | 
+--------------------------+ 
|   privateIP  | 
+--------------------------+ 
| 172.xx.x.xx    | 
+--------------------------+ 
||   tags   || 
|+--------------+---------+| 
||  Key  | Value || 
|+--------------+---------+| 
|| Name  | xxxxx || 
|| Autobuild | xxxxx || 
|| Environment | xxxxx || 
|+--------------+---------+|