[英]How to get public ip of an EC2 instance from aws CLI by instance id?
I have an instance that I start through aws cli: 我有一个通过aws cli启动的实例:
aws ec2 start-instances --instance-ids i-00112223333444445
Instance does not have a static public IP. 实例没有静态公共IP。 How can I get instance public ip through CLI knowing the ID i-00112223333444445?
如何通过CLI知道ID为i-00112223333444445的实例来获取公共IP?
Try the following command: 尝试以下命令:
aws ec2 describe-instances --instance-ids $instance_id \
--query 'Reservations[*].Instances[*].PublicIpAddress' \
--output text
If the EC2 instance has a public IP address, this command will return it. 如果EC2实例具有公共IP地址,则此命令将返回它。
Links: 链接:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.