mirror of https://github.com/pulumi/pulumi.git
b74842933d
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: ```go package main import ( "github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/compute" "github.com/pulumi/pulumi-gcp/sdk/v8/go/gcp/organizations" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" "github.com/pulumi/pulumi/sdk/v3/go/pulumi/config" ) func main() { pulumi.Run(func(ctx *pulumi.Context) error { conf := config.New(ctx, "") billingAccountId := conf.Require("billing-account") billingAccount, err := organizations.GetBillingAccount(ctx, &organizations.GetBillingAccountArgs{ BillingAccount: &billingAccountId, }) if err != nil { return err } project, err := organizations.NewProject(ctx, "my-project", &organizations.ProjectArgs{ Name: pulumi.StringPtr("project-go"), AutoCreateNetwork: pulumi.BoolPtr(false), DeletionPolicy: pulumi.StringPtr("DELETE"), BillingAccount: pulumi.StringPtr(*billingAccount.BillingAccount), }) if err != nil { return err } zonesOutput := compute.GetZonesOutput(ctx, compute.GetZonesOutputArgs{ Region: pulumi.StringPtr("us-central1"), Project: project.ProjectId, Status: pulumi.StringPtr("UP"), }, pulumi.DependsOn([]pulumi.Resource{project}), ) ctx.Export("zones", zonesOutput) return nil }) } ``` With the change to wait for the CustomResource.ID, this correctly returns an unknown during preview for `zones`. |
||
---|---|---|
.. | ||
config | ||
errors | ||
generate | ||
internals | ||
provider | ||
alias.go | ||
alias_test.go | ||
asset.go | ||
callback.go | ||
context.go | ||
context_test.go | ||
internals.go | ||
log.go | ||
mocks.go | ||
printf.go | ||
printf_test.go | ||
provider.go | ||
provider_linked.go | ||
provider_test.go | ||
resource.go | ||
resource_set.go | ||
resource_test.go | ||
rpc.go | ||
rpc_test.go | ||
run.go | ||
run_test.go | ||
stack_reference.go | ||
stack_reference_test.go | ||
transform.go | ||
transformation.go | ||
type_conversions.go | ||
types.go | ||
types_builtins.go | ||
types_builtins_test.go | ||
types_contravariance_test.go | ||
types_test.go | ||
urnset.go |