List public IP addresses of EC2 instances

后端 未结 5 816
無奈伤痛
無奈伤痛 2020-12-13 08:46

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

I tried to pipe the output to jq with aw

5条回答
  •  一向
    一向 (楼主)
    2020-12-13 09:08

    The below command would list the IP addresses of all your running EC2 instances

    aws ec2 describe-instances | grep PublicIpAddress | grep -o -P "\d+\.\d+\.\d+\.\d+" | grep -v '^10\.'
    

    Hope that answers your query...

    But this works without all the errors about access:

    wget -qO- http://instance-data/latest/meta-data/public-ipv4/|grep .
    

提交回复
热议问题