'possible to discover ENI Ip address via EC2 instance meta-data?

Im using ECS to create a service that uses the awsvpc network type - thus creating ENIs on my host instances giving my ec2 instances two internal network configs and two internal Ips.

I cant seem to be able to pull out any ENI information out of the instance metadata http://169.254.169.254/latest/meta-data/ - only the original internal Ip.

Is there any way i can discover the ENI ip via querying the instance metadata or other method from within the docker container without resorting to aws-cli ?



Solution 1:[1]

it is possible to get the ip address of the ENI adapter with the instance meta-data:

curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/

then sub in the macs to get both private ips:

curl http://169.254.169.254/latest/meta-data/network/interfaces/macs/<mac address>/local-ipv4s

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 steveinatorx