Hi folks! Is there a way to know the reason for a ...
# getting-started
b
Hi folks! Is there a way to know the reason for a resource replacement? I’m not sure what happened, but now Pulumi wants to recreate everything just to change
name
. For example,
gcp.Address
Copy code
++gcp:compute/address:Address: (create-replacement)
        [id=projects/sandbox-pulumi/regions/us-central1/addresses/retool-b629537]
        [urn=urn:pulumi:sandbox::infra::gcp:compute/address:Address::retool]
      ~ name: "retool-b629537" => "retool-5775aba"
    +-gcp:compute/address:Address: (replace)
        [id=projects/sandbox-pulumi/regions/us-central1/addresses/retool-b629537]
        [urn=urn:pulumi:sandbox::infra::gcp:compute/address:Address::retool]
      ~ name: "retool-b629537" => "retool-5775aba"
Even though this
Address
has no dependencies.
pulumi refresh --yes
didn’t help. The only workaround I found is leaving
pulumi.IgnoreChanges([]string{"name"})
everywhere like here
Copy code
ip, err := compute.NewAddress(ctx, "retool", nil,
		pulumi.DependsOn([]pulumi.Resource{enabledServices.Compute}),
		pulumi.IgnoreChanges([]string{"name"}))
I noticed
name
is different in
outputs
and
inputs
in the json state file. If I make them congruent, Pulumi doesn’t want to replace this resource anymore. I am not sure what broke these
name
in the state. Could have been updates to Pulumi and GCP provider. 🤷🏻‍♀️
l
As you figured out,
name
is the reason that the replacement was suggested. To answer your original question: if an attribute changes in your preview, and if that attribute has the recycle icon in the registry docs, then a replace is required. For example, in this case, the docs are here: https://www.pulumi.com/registry/packages/gcp/api-docs/compute/address/#properties And
name
has the recycle icon:
b
@little-cartoon-10569 The thing is the
name
didn’t change in GCP. For some reasons they regenerated in
inputs
of the state.
l
Yes, I can't answer that part. It has happened to me in the past too. Generally,
pulumi refresh
eventually fixes it, but the effort involved is significant. I generally associate this with changing providers, but I have no proof.