I'm curious how that async stuff works under the h...
# general
t
I'm curious how that async stuff works under the hood in terms of generating a declarative state and then applying it. Since imperative languages are generally serially interpreted I wonder how often people will run into these issues moving forward
i
It might be a bit esoteric but you can think of Pulumi as a “graph executor” - it receives a graph of your desired state, turns that graph into a set of concrete steps that need to be completed, and then executes them all in order, possibly in parallel. Since Pulumi lets you inspect the outputs of resources that are getting created as part of this graph execution, it’s naturally the case that the ouptuts of a resources resolve asynchronously, as resources get created and Pulumi advances the execution of the graph. The asynchrony mirrors data flow dependencies between resources, and really when you’re writing a Pulumi program what you’re doing is connecting together different asynchronous streams of data. It’s confusing when these things don’t happen synchronously, but doing things asynchronously lets us present a facade of an imperative object model on top of a declarative, asynchronous data model.
People do run into this often, and it’s unfortunate that this leaks into user programs the way that it does. We thought hard about this and weren’t able to come up with anything better that still had the properties that we wanted
t
thank you for the explanation, that was very well presented
you're just making me want to find more reasons to give pulumi a whirl at work
i
yay! 😄
I think the only time you really only ever need to think about asynchrony with Pulumi programs is when you interact with data sources - I think we do a pretty OK job hiding it everywhere else.