There's an inherent dependency analysis that Pulumi does by default. The key to thinking about this is that your entire code will run
before any resources are modified/created/destroyed. It's basically making a list of instructions to do on your resources. If you run a function that depends a previously configured resource, it knows to put that further down the list.
That said, if there's a very specific order you need things to run it, you can use the Depends On function:
https://www.pulumi.com/docs/concepts/options/dependson/
This can override the automatic inference, which can cause problems, so use with care.