https://pulumi.com logo
#python
Title
# python
w

white-terabyte-21934

06/02/2022, 7:36 AM
Hello , Looking for an advice , I am trying pulumi with python and would like to know the better usage of Output . • Creating a resources let say r = xx.CreateResources(…) ==> r (A pulumi output object) • Would like to extract the raw value of a property ,let say r.http_url (which is again a type of
pulumi.output.Output object
. • Would like to print these values via a print statement (like terraform output format) ,what is the best way to fetch the value via Ouput() method ?
b

billowy-army-68599

06/02/2022, 8:23 AM
hey @white-terabyte-21934 : Output usage is usually fairly clear, the values are asynchronously retrieved. You should try to avoid creating resources after resolving an output yourself (ie, when using
apply
) because previews won't be accurate. if you want to extract the resolved property of an output (what you call raw) you would use an
apply
if you want to just print them, again, just use an apply. if you want to print them to console, use
pulumi.export
1
🙌 1
w

white-terabyte-21934

06/03/2022, 9:06 AM
If i may ask ,do you have a sample snippet to see how to get the value with out lambda , • What i am trying to do is ,using radmon string , get a random value and use the value as a prefix for pulumi and non pulumi actions , for pulumi resources its more easy that i can use radmon.result as is ,but for others its not getting around .
Copy code
print (f"xxx_{random_string().result") ==> Would want to use the value as raw , not with in a lambda with a function return or an assigned variable than can parse to next function or class object calls
i got it working using an external file write or OS.env but any other better way ?
b

billowy-army-68599

06/03/2022, 10:18 AM
You can only do this inside an apply. What are you trying to pass the value to?
w

white-terabyte-21934

06/03/2022, 10:19 AM
i am parsing as a uniq ref to resource that are created by pulumi as well as reference to some other local updates (outside of pulumi control) • like OCI code repo (under pulumi) • pygit remote ref - for a specific external python actions ,but to refer under the same commit message /id