Answers I found so far (e.g. Find out public ip address of the EC2 server) suggest using wget
or curl
to reach the server.
They are not useful for me because my ec2 instances are not reachable from the internet directly.
I have tried
aws ec2 --profile prod describe-instances --filters Name=instance-id,Values=i-00914683ababcba7eb1
But there are no IPs in the returned JSON result.
Which aws
CLI command I can use to retrieve this info?
Generally you can do it with --query filter.
If you need the private IP address only:
If you need the public ip address only:
Or you can have both:
Of course you can have the output in json format too. Just change
--output text
to--output json
More information about --query filters.
It turns out I can do this
and it will return
My command in the question failed because, coincidentally, that instance was being shut down. So there was no
NetworkInterfaces
section in the result.