https://pulumi.com logo
Title
c

careful-petabyte-65672

04/01/2022, 8:32 AM
Hi A question, If I have 2 stacks and I use
StackRefrence
to get output of stack 1 to use in stack 2, if I do
pulumi up
to both stacks at once, will stack 2 wait for stack 1 to produce the output before using it? Thanks!
e

echoing-dinner-19531

04/01/2022, 9:38 AM
No. There's no synchronisation like that between stacks.
c

careful-petabyte-65672

04/02/2022, 7:14 AM
Can I create such mechanism by polling the output? I'm using python.
e

echoing-dinner-19531

04/02/2022, 7:22 AM
You could use a shell script or the automation api to keep asking for "stack output" till you get something and then run "pulumi up" after
c

careful-petabyte-65672

04/02/2022, 9:17 AM
I want to ask it while the deployment is running do
pulumi up
to all and when I need the output do the poling.
e

echoing-dinner-19531

04/02/2022, 10:18 AM
Right you can do that using automation api. It's a bit of an odd program setup because it's going to just block "pulumi up" till the outputs resolve, but it's possible: https://www.pulumi.com/docs/reference/pkg/nodejs/pulumi/pulumi/automation/#Workspace-stackOutputs
c

careful-petabyte-65672

04/02/2022, 10:24 AM
I thought of something like this:
while True:
      my_stack = pulumi.StackReference("my-stack")
      value = my_stack.get_output(key)
      if value:
         return value
      time.sleep(10)
e

echoing-dinner-19531

04/02/2022, 11:25 AM
That will crash in a pulumi program because it will try to create two resources called "my-stack"
You need to use automation api to do this
c

careful-petabyte-65672

04/02/2022, 5:32 PM
I'm using automation and LocalWorkspace I will need to refresh the stack each time I query the outputs right?`
e

echoing-dinner-19531

04/02/2022, 5:41 PM
stackOutputs
will do a fetch each time you call it
c

careful-petabyte-65672

04/03/2022, 1:16 PM
Thanks!