-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid calling invokes with dependencies on unknown resources (#441)
.NET implementation of pulumi/pulumi#18133 DependsOn for resources is an ordering constraint for register resource calls. If a resource R1 depends on a resource R2, the register resource call for R2 will happen after R1. This is ensured by awaiting the URN for each resource dependency before calling register resource. For invokes, this causes a problem when running under preview. During preview, register resource immediately returns with the URN, however this does not tell us if the resource "exists". Instead of waiting for the dependency's URN, we wait for the ID. This tells us that whether a physical resource exists (if the state is in sync), and we can avoid calling the invoke when it is unknown. The following example fails without this change: ```csharp using Pulumi; using Pulumi.Gcp.Organizations; using Pulumi.Gcp.Compute; using System.Collections.Generic; return await Deployment.RunAsync(async () => { var config = new Config(); var billingAccountId = config.Require("billing-account"); var billingAccount = await GetBillingAccount.InvokeAsync(new GetBillingAccountArgs { BillingAccount = billingAccountId }); var project = new Project("project", new ProjectArgs { BillingAccount = billingAccount.Id, Name = "project-nodejs", AutoCreateNetwork = false, DeletionPolicy = "DELETE", }); var zones = GetZones.Invoke(new GetZonesInvokeArgs { Project = project.ProjectId, Region = "us-central1" }, new InvokeOutputOptions { DependsOn = { project } }); return new Dictionary<string, object?> { ["zones"] = zones, }; }); ```
- Loading branch information
Showing
4 changed files
with
85 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
component: sdk | ||
kind: bug-fixes | ||
body: Avoid calling invokes with dependencies on unknown resources | ||
time: 2025-01-06T14:03:11.053995+01:00 | ||
custom: | ||
PR: "441" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters