How to get DNS address from AWS machine in my IaaS charm code

I’m trying to use the operator framework with juju 2.8

I need some code example on how I can get the DNS address pictured below because I don’t understand how to achieve this. Apparently, juju has access to that somehow, I just can’t understand how.

I probably can’t help as I’m new to the framework, but it occurs to me that it might help to know why you need the machine’s IP address rather than a unit’s address etc? I bet that would help someone with knowledge of the framework better understand the situation and offer advice.

For example, are you needing this machine IP address while processing a particular event such as start or a relation joined/changed event?

1 Like

I need it to configure a trusted domain in config. php for nextcloud. It’s required to access the site as admin.

I the start hook.


Thanx to @jamesbeedy

… and some more…

… now I just need to figure out how to do this in “ops”.

1 Like

Hi Erik,

The first step is to understand why you need the IP address. Juju models not just the machines/applications but also the network(s) connecting the applications. Juju has a concept of spaces - you can read more here: - which allows an administrator to restrict which segment of the network specific intra-application or inter-application traffic is routed over.

This means to get an IP address, your charm needs to have a relation. The simplest use case, would be for setting up a cluster, so you want traffic between units of the same application. In which case you need two things:
First, you need a peer relation, which can be setup in metadata.yaml:

        interface:  application-peer-name

Then, from your config-changed or relation-changed event handlers you could access the associated address with this code:

1 Like

The public-address is not yet exposed in the Operator Framework.

The result, is that the public-address is different depending on which cloud you deploy on.

ingress-address is not equal to the public-address.

I placed an issue about this in github: