Private IPs vs Public Ips


#1

Hello! I’ve noticed something when using sys.ip in bindings:

https://www.habitat.sh/docs/reference/#sys

It seems that sys.ip always returns the private IP of an AWS instance, rather than the public IP. Is there any way to specify that this should be the public IP for the instance, rather than the private IP?


#2

I think some other folks have run into this. But I can’t for the life of me remember what the solution was. Effectively I think that we try to make a determination about which nic is the “primary” interface and that’s what gets assigned to sys.ip. I’m not certain if theres a way around that. Would be good to get some input from @christophermaier and @reset.


#3

Long ago I saw the code and it was hardcoded. Depending on when you need it, you could make use of ifconfig to bash scrape the other IPs. Then somehow feed it to a template or perhaps an environment var.