列出 EC2 实例的公有 IP 地址 [英] List public IP addresses of EC2 instances

查看:26
本文介绍了列出 EC2 实例的公有 IP 地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Bash 列出我的 EC2 实例的公共 IP 地址,用分隔符(空格或换行符)分隔.

I want to list the public IP addresses of my EC2 instances using Bash, separated by a delimiter (space or a new-line).

我尝试使用 aws ec2 describe-instances 将输出通过管道传输到 jq |jq,但似乎不能只隔离 IP 地址.

I tried to pipe the output to jq with aws ec2 describe-instances | jq, but can't seem to isolate just the IP addresses.

这是否可以通过 aws 单独完成,指定 jq 的参数,或者其他完全的东西?

Can this be done by aws alone, specifying arguments to jq, or something else entirely?

推荐答案

直接来自 aws cli:

aws ec2 describe-instances 
  --query "Reservations[*].Instances[*].PublicIpAddress" 
  --output=text

这篇关于列出 EC2 实例的公有 IP 地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆