(Not sure if this is specifically related to Pytho...
# python
c
(Not sure if this is specifically related to Python or not, but here goes...) Is there a trick to get the Public IP to print out on the first run of
pulumi up
? This is on Azure, but it shows in the preview that it will output the public IP, but it wont display it until I run
pulumi up
a second time.
h
you mean the exact IP of an azure
PublicIP
?
no, since it's assigned by azure, you can't know what the actual address is until you actually create the
PublicIP
c
Right, but after I create the IP, it should be available to me, right? So if I have (pseudo-code):
Copy code
pip=network.PublicIPAddress(<foo...>)
pulumi.export("label", pip.ipaddress)
h
yup, it should be in the outputs
the docs have an "outputs" section, they're properties on the realized resource (
pip
above)
c
Yeah, I can get it to output, but it doesn't output after the initial creation, I have to run
pulumi up
again for it to output it.
h
that's weird,
pulumi up
should have it after you've confirmed and it's actually run
pulumi preview
won't have it
after
pulumi up
,
pulumi stack output
should have it
c
First pic is the preview before the first run, second is the results of the first run, third is the preview of a second
pulumi up
While it isn't complete impossible that I'm doing something terribly wrong, it really doesn't look like it.
h
oh yeah, previews often hide unchanged resources and outputs
there might be a flag to get it to not do that
c
I don't care that it is hidden in the preview (I get that), but I have to run
pulumi up
twice in order to output my Public IP
h
oh, misread it, i see
c
I'm destroying now and will re-build and run
pulumi output
after the run to see if the pip is there before running it a second time.
h
yup, that's weird
i haven't seen that before
c
Ok, so it isn't just me that thinks this is weird. Cool!
h
assuming you're not doing something conditional (or other weirdness) in your code, the resource and the output should be present in the first run
c
I'm not doing anything overly special. No weird conditionals or anything
h
huh
c
Here is an example of my code run the first time.
h
huh
yup, that's Weird™️
c
Well, glad I could stump someone....
lol
h
so that reads like the preview is expecting an output, but when it goes to execute it, it's not there
oh, i wonder if the PublicIP is doing some kind of multi-stage thing? like, just because the resource is created doesn't mean the IP is actually assigned?
ok, so looking through https://www.pulumi.com/registry/packages/azure-native/api-docs/network/publicipaddress/ i see two things: 1. there is a
.provisioning_state
, but no specifics 2. it's
.ip_address
not
.ipaddress
but for some reason that's not an error?
c
Here I go necromancing this thread... but the problem was I was building a Dynamic public IP which is not assigned until it is needed. I swapped to a Static IP and it is defined when created.