I would like to get all IP addresses for the ec2 instance. I am looking at the CLI aws ec2 describe-instances and I see that we have 2 places where we have IP address. I understand each interface can have own public IP/private IP and can belong to different subnets hence the fields under Network Interfaces. But what is not clear to me why we have IP address (public/private) and subnet under instance. Won't that data be part of one of the interface. Is there anything this signifies. why this duplication?``
e.g. aws ec2 describe-instances
"Instances": [
{
*** I have IP address and subnet here ***
"PrivateIpAddress": "10.0.0.19",
"SubnetId": "subnet-12345678",
"NetworkInterfaces": [
***I also have IP address, subnetId for each interface here**
"PrivateIpAddress": "10.0.0.19",
"SubnetId": "subnet-12345678",
}
]
DescribeNetworkInterfaces
API call (aws ec2 describe-network-interfaces command). This contains additional details about the network interfaces attached to the instance. Some people may find this information useful (like the mac address or the network interface id). – krishna_mee2004