Once I export a variable like : pulumi.export("Nod...
# general
c
Once I export a variable like : pulumi.export("NodeName", node) . (btw node is of type pulumi.Output I guess). How do I access it and print it ? print(NodeName) doesnt work.
w
The goal of
pulumi.export
is to make it available outside of Pulumi. You can
pulumi stack output
to get all outputs or
pulumi stack output NodeName
to get just that one. From within the program, you can print an output with:
node.apply(lambda n: print(n))
or just
node.apply(print)
Note that those will only print the value once it is available.
c
how do i get it into a variable?
w
You get the value within the function passed to apply. You can write a
def myfunc(n):
and then write code within that function that does whatever you want, and call
node.apply(myfunc)
. See https://www.pulumi.com/docs/intro/concepts/programming-model/#outputs for much more detail on this.
c
Copy code
h = str
def myfunc(n):
    h = n

node.apply(myfunc)

print ( "h = {}".format(h))  # prints  h = <class 'str'>
w
The equivalent of what you are trying to do there in Pulumi would be:
Copy code
def myfunc(n):
    print ( "n = {}".format(n)) 
node.apply(myfunc)
If your real example is something different than this - please share it and I can suggest how to structure in Pulumi.