https://pulumi.com logo
i

important-vegetable-39003

12/27/2021, 1:18 PM
Hi folks, does it matter in what order you define resources in your code? Or does Pulumi intelligently select the right order?
For example usually creating an ingress with specified ip before creating the ip will result in an error. So in theory this would fail:
Copy code
new Ingress(name, ingressTemplate);
new GlobalAddress(ipName, {
  name: ipName,
  project: con.glob.project,
});
But what I'm trying to ask is if Pulumi cares about the order?
e

elegant-window-55250

12/27/2021, 1:26 PM
It doesn't matter in what order you place them, Pulumi will try to apply all of them if there are no dependencies.
Let's say that your ingress are going to use the GlobalAddress resource, you can reference the GlobalAddress, which makes it a dependency.
But let's say you use the
ipName
variable as reference in the Ingress, it'll fail, as there are no way for Pulumi to register the dependency.
i

important-vegetable-39003

12/27/2021, 1:29 PM
So how would I tell pulumi that the address is a dependency for ingress?
e

elegant-window-55250

12/27/2021, 1:29 PM
I would probably write it something like this:
Copy code
const address = new GlobalAddress(ipName, {
  name: 'the-global-ip',
  project: con.glob.project,
});
new Ingress(name, { ipAddress: address.ip });
i

important-vegetable-39003

12/27/2021, 1:29 PM
ip name is part of the ingress config, yes
e

elegant-window-55250

12/27/2021, 1:30 PM
You could also declare the dependency manually, like this:
Copy code
const address = new GlobalAddress(ipName, {
  name: ipName,
  project: con.glob.project,
});
new Ingress(name, ingressTemplate, { dependsOn: address });
i

important-vegetable-39003

12/27/2021, 1:31 PM
That's what I'm looking for, thanks!
e

elegant-window-55250

12/27/2021, 1:31 PM
👍