0

As many of you know AWS have Auto-Assigned "Public" IP's and Elastic IP's for the instances, I can get the Elastic IP's via cli with the describe-addresses command: https://docs.aws.amazon.com/cli/latest/reference/ec2/describe-addresses.html

Example:

aws ec2 describe-addresses --filters "Name=instance-id,Values=InstanceWithEIP_id" --output=json

And it returns the EIP but I want to know how can I get the Auto-Assigned IP via cli because the command with a instance-id from a non elastic-ip instance returns nothing.

Thanks

1

You can use the aws describe-instances command instead, like so:

aws ec2 describe-instances --filters "Name=instance-id,Values=i-56b4192a" --output=json | jq -r '.Reservations[].Instances[].NetworkInterfaces[].Association.PublicIp'
54.111.237.129
  • Hi, thanks for your reply, as I told in the answer the command describe-addresses return nothing because the instance that I want to filter does not have an Elastic IP, instead it have an Auto-Assigned Public IP. – Nicolás Santisteban Aug 22 '18 at 17:47
  • Sorry, just edited my answer. – Itai Ganot Aug 22 '18 at 17:57
  • as I'm working on Windows I have to delete the ' symbols: aws ec2 describe-instances --filters "Name=instance-id,Values=xxxxxxxxx" --output=json | jq -r .Reservations[].Instances[].NetworkInterfaces[].Association.PublicIp and It worked. Thanks a lot – Nicolás Santisteban Aug 22 '18 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.