Annotate resources with URNs to prevent accidental deletion #2999
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed changes
User feedback here indicates that upsert behavior is actually desirable, and the concern is more along the lines of preventing accidental resource deletions. I agree with all the concerns -- while it's good to be aware of aliases and deleteBeforeReplace, the fact remains that our default behavior is still very foot-shooty.
I liked this proposal and wanted to see if it was feasible, because it could potentially provide a stricter/safer execution mode without requiring any additional effort from the user.
To quickly recap, #2948 describes a situation where a resource is renamed in Pulumi but unchanged in the cluster.
The engine plans this as create
default/foo
followed by deletedefault/foo
, so Pulumi thinks it's created a new resource but the end result is actually a deletion. Yikes!!The proposal is to annotate the object in the cluster with its URN and then only perform deletion when the URN matches what we expect to be deleting. This is not hard to implement, but there are a couple caveats:
Apply
that doesn't actually patch the resource, but it does use a different field manager from what's already recorded in the cluster. With this proposal, the create step would modify the resource to update its ARN annotation and this generates a SSA conflict. We could handle this a few ways:In any case, this is a big enough change that it would need to be opt-in -- what would we call the config to enable this?
Refs #2926
Refs #2948