Skip to content

prevent planning a resource deletion when deletion_protection = true is set #22997

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
antdking opened this issue May 23, 2025 · 2 comments
Open

Comments

@antdking
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
  • Please do not leave +1 or me too comments, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.
  • If an issue is assigned to a user, that user is claiming responsibility for the issue.
  • Customers working with a Google Technical Account Manager or Customer Engineer can ask them to reach out internally to expedite investigation and resolution of this issue.

Description

When running a plan to delete a resource that has deletion_protection = true (or where it's not set and the default is true), the plan shows the resource will be deleted.

It's not until the plan is applied that the deletion is prevented.

This leads to confusion to end users, especially where apply happens in a CI environment.

The expected behaviour is that when a resource with deletion_protection = true set is marked for recreation or deletion, the plan should fail.

New or Affected Resource(s)

  • google_workflows_workflow
  • google_cloud_run_v2_service
  • Potentially others that implement deletion_protection

Potential Terraform Configuration

References

No response

@antdking antdking changed the title deletion_protection = true while planning a deletion allows plan to pass prevent planning a resource deletion when deletion_protection = true is set May 23, 2025
@github-actions github-actions bot added forward/review In review; remove label to forward service/run service/workflows labels May 23, 2025
@BBBmau
Copy link
Collaborator

BBBmau commented May 27, 2025

Note: We don't think this is something that can be handled in the provider

Ideally core would support deletion_protection on resources, perhaps supporting a lifecycle parameter?

@BBBmau BBBmau added this to the Backlog milestone May 27, 2025
@BBBmau BBBmau self-assigned this May 27, 2025
@melinath
Copy link
Collaborator

Alternatively, if there were a hook we could use to raise an error at plan time consistently (for both deletion and recreation), potentially without suppressing the display of the diff - that could work. We don't think CustomizeDiff would be sufficient in its current form. I'm not clear on whether plugin framework has better options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants