Hey guys! I have a weird issue where `delete_befor...
# python
Hey guys! I have a weird issue where
is simply not working. Here is how I do it:
Copy code
    # More instance config here
However, pulumi simply ignores it. Each time the resource changes (the name changes), it first creates the new resource, and then deletes the old one. What am I missing here?
Sounds like a bug. Mind opening an issue at github.com/pulumi/pulumi/issues ?
Could it be because the resource name changes? This sounds like the issue here. This is a follow up to my question in the #general channel: https://pulumi-community.slack.com/archives/C84L4E3N1/p1610047032187200 I'll elaborate my use case: I'm using a container optimized os instance, which supports cloud-init as instance metadata. I have a container version in this instance metadata, and basically the only change that could happen to the instance is when the container version changes - so I need to simply update the metadata. However, in pulumi, when metadata changes it simply updates the instance - but then the cloud init won't run. I have another requirement that 2 instances cannot be run at the same time. Basically I need the instance to be always recreated on any change, so I've added the "version" variable into the resource name. But I also need to make sure that the old instance is removed before the new instance is created.
Basically an option like
would have solved the issue for me, but there is no such thing. Should I perhaps open an issue with feature request instead?
@gentle-diamond-70147 I would really appreciate your opinion on this
Changing the resource name is effectively creating a new resource as far as the Pulumi engine is concerned, so that's why
isn't being honored there. If there's some other property you can change that would cause the resource to be replaced (e.g. like
?), then
should work in that case. Alternatively, you could call
pulumi up --target-replace ...
to replace the instance which should honor
. Would that work for you?
@gentle-diamond-70147 --target-replace assumes that I know that the instance metadata has changed and therefore I'll be running it on the specific urn. However, in an automated gitops continuous deployment flow you never know what has changed, that's why I'm searching for an option like
or some other workaround here..
I see. I'm not aware of a way to achieve what you're wanting at this time unfortunately.
Do you mind opening an issue at https://github.com/pulumi/pulumi with more details about the functionality you'd like?
@gentle-diamond-70147 thanks, I've opened an issue - hopefully I've explained it well enough: https://github.com/pulumi/pulumi/issues/6130