Question:
Using the aws CLI
, how can I retrieve the private IP address of an EC2 instance given its instanceID?
When I do:
1 2 |
aws ec2 describe-instance-status --instance-ids |
I get other information, but not the private IP addresses such as:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
{ "InstanceStatuses": [ { "InstanceId": "XXXXX", "InstanceState": { "Code": 16, "Name": "running" }, "AvailabilityZone": "us-east-1a", "SystemStatus": { "Status": "ok", "Details": [ { "Status": "passed", "Name": "reachability" } ] }, "InstanceStatus": { "Status": "ok", "Details": [ { "Status": "passed", "Name": "reachability" } ] } } ] } |
Answer:
Try describe-instances
instead. Private IP Address isn’t returned with describe-instance-status because that command describes system and instance status, primarily concerning itself with hardware/issues or scheduled events.
Per the “Output” section of the describe-instances documentation, part of the output of describe-instances is a string PrivateIpAddress
.
Example usage:
1 2 |
aws ec2 describe-instances --instance-ids |