如何使用aws cli列出ipaddress和名称标签
aws ec2 describe-instances --query "Reservations[*].Instances[*].PrivateIpAddress[*]" --output table
给我ipaddess的列表,但我需要IP地址和名称标签。
请帮忙。
答案 0 :(得分:1)
您可以执行以下操作
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].{privateIP:PrivateIpAddress, tags:Tags[*]}"
如果需要,您可以添加table
输出,但如果您有多个标记,则可见性不是很好
aws ec2 describe-instances \
--query "Reservations[*].Instances[*].{privateIP:PrivateIpAddress, tags:Tags[*]}" \
--output table
输出将是
----------------------------
| DescribeInstances |
+--------------------------+
| privateIP |
+--------------------------+
| 172.xx.x.xx |
+--------------------------+
|| tags ||
|+--------------+---------+|
|| Key | Value ||
|+--------------+---------+|
|| Name | xxxxx ||
|| Autobuild | xxxxx ||
|| Environment | xxxxx ||
|+--------------+---------+|