Open stooj opened 1 month ago
Hi @stooj - thank you for filing this issue. It sounds like there's a workaround for in the meantime but we'll take a look.
This sounds like a structural resource which needs DeleteBeforeReplace in the schema. For example: https://github.com/pulumi/pulumi-aws/blob/3ff4fa4ddc54bcef6d043e7c62e0e881c6ecdaa5/provider/resources.go#L2435
Thanks for looking at this @rshade
I tested my repro with v8.8.0 and it still exhibits the same behaviour as before, so this isn't fixed 🙁
Changing the name
of the pulumi resource changes the URN, so pulumi removes the old resource and creates a new one.
But because nothing on the GCP side is changing, GCP doesn't see any differences.
And pulumi creates first, then deletes. So what I think is happening is:
{"a" = 1, "b" = 2}
{"a" = 1, "b" = 2}
This issue wouldn't happen if any other properties were changed on the resource.
But Pulumi deleting resources without alerting the user is a footgun that we should warn the user about. Can the engine detect a URN change when nothing else is changed?
Do we support changing the names of resources?
Aliases is your answer here. We will be adding DeleteBeforeReplace back once we get conditional DBR, which will solve it getting deleted in the second step, however, renaming of resource is always handled via Aliases, that way its a NoOp.
Sure, I agree that using aliases are the fix.
But we need to protect users from this if they don't know they need to use aliases, because at the moment pulumi deletes resources without telling you about it.
We reverted DeleteBeforeReplace by default for these resources: https://github.com/pulumi/pulumi-gcp/pull/2595
However, it looks like the IAMMember can have an unconditional DeleteBeforeReplace - it seems unlikely that it ever works without DeleteBeforeReplace
We could add it back for IAMMember, IAMPolicy and any other resources which never work without DeleteBeforeReplace - these do not need a conditional DeleteBeforeReplace
@VenelinMartinov yep, I can do that later.
@stooj I would say after that you need a pulumi/pulumi
ticket because this is about comparing selfLinks
to determine replacement strategy versus the urn.
@stooj I think https://github.com/pulumi/pulumi/issues/15982 captures the problem you described
Describe what happened
When modifying the name of a
gcp.projects.IAMMember
, the resource is deleted on changes.The same thing happens with
gcp.serviceaccount.IAMMember
.Pulumi deletes the old resource, and the create action "succeeds", but the resource is not actually created.
To reproduce:
pulumi up
the code belowgcloud projects get-iam-policy ticket-5866 --flatten="bindings[].members" --format="table(bindings.members)"
projectMember
name (say,ticket-5866
->ticket-5866foo
)pulumi up
gcloud
command.Sample program
Log output
change-iam-member.txt
Affected Resource(s)
gcp.projects.IAMMember
gcp.serviceaccount.IAMMember
Output of
pulumi about
Tested with pulumi v3.113.0 and v3.134.1, and with pulumi/gcp 8.3.1.
Additional context
A
pulumi up --refresh
will fix this, but since pulumi thinks the recreation succeeds the user isn't given any warning that things didn't actually work.Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).