Hi A question, If I have 2 stacks and I use `Stack...
# general
c
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
No. There's no synchronisation like that between stacks.
c
Can I create such mechanism by polling the output? I'm using python.
e
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
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
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
I thought of something like this:
Copy code
while True:
      my_stack = pulumi.StackReference("my-stack")
      value = my_stack.get_output(key)
      if value:
         return value
      time.sleep(10)
e
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
I'm using automation and LocalWorkspace I will need to refresh the stack each time I query the outputs right?`
e
stackOutputs
will do a fetch each time you call it
c
Thanks!