https://pulumi.com logo
c

colossal-australia-65039

03/03/2021, 11:21 PM
How can I use the automation API to handle when one stack depends on outputs from another stack? Right now I'm using
StackReference
but it only ties the stacks together with a string value (the name of the stack). I'd like to do this with an object reference so I can run a single command to bring up multiple stacks all in the correct order. Is something like this possible?
l

little-cartoon-10569

03/03/2021, 11:33 PM
Yep. Just await the first up, then run the 2nd up. You can use inline programs to make it clearer, but both methods work.
l

lemon-agent-27707

03/04/2021, 12:18 AM
Here's an example of a go program that splits up a deployment across two stacks with automation api: https://github.com/pulumi/automation-api-examples/blob/main/go/multi_stack_orchestration/main.go
First it deploys the bucket in one stack, then it references that bucket as a stack output and it feeds that bucketId into a function that generates the next program. You can see here that the program for the object stack is parameterized to curry the bucketId.
c

colossal-australia-65039

03/04/2021, 12:25 AM
great! thanks guys!