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

high-barista-92349

07/12/2023, 10:18 AM
Hi all, is there a way to get stack output from pure python without using pulumi cli? Something like the following (doesn’t work)
Copy code
import pulumi        
ref = pulumi.stack_reference.StackReference(name="unused", stack_name="stack")
resp = ref.get_output("output1")
print(resp)
And running the above with
python file.py
b

billowy-army-68599

07/12/2023, 2:36 PM
You need to do an apply for an output. Have you read https://www.pulumi.com/docs/concepts/inputs-outputs/
h

high-barista-92349

07/13/2023, 8:20 AM
I did try apply as well and that did nothing
Copy code
import pulumi        
ref = pulumi.stack_reference.StackReference(name="unused", stack_name="stack")
resp = ref.get_output("output1").apply(print)
I suspect apply would only work if run via pulumi cli
b

billowy-army-68599

07/13/2023, 2:20 PM
oh, yes, they’re only available in the pulumi CLI
c

colossal-airplane-46873

07/24/2023, 8:14 PM
I am interested in this as well. Is there a way to execute pure Python script with Pulumi context so the values can be fetched? Something like this:
Copy code
pulumi run file.py
m

millions-furniture-75402

07/24/2023, 8:25 PM
The automation api
c

colossal-airplane-46873

07/24/2023, 8:53 PM
Thank you so much. What I needed was Automation API's Local Program 👍
3 Views