feat(cloud_project): add client-side deletion_protection attribute#1270
Merged
amstuta merged 2 commits intoovh:masterfrom Mar 28, 2026
Merged
Conversation
Signed-off-by: Pascal T. <[email protected]>
Signed-off-by: Pascal T. <[email protected]>
0246aed to
f837ce5
Compare
amstuta
approved these changes
Mar 28, 2026
Collaborator
amstuta
left a comment
There was a problem hiding this comment.
Thanks for your contribution @pascalinthecloud !
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Add a client-side
deletion_protectionattribute to theovh_cloud_projectresource. When set totrue, Terraform will refuse to destroy the resource, preventing accidental deletion of public cloud projects. Users must explicitly setdeletion_protection = falseand runterraform applybefore the resource can be destroyed.This is a client-side only implementation since the OVH API does not support deletion protection. The value is stored in Terraform state, so it also protects against removal of the resource block from the configuration — unlike Terraform's built-in
prevent_destroylifecycle meta-argument, which only blocksterraform destroybut does not prevent deletion when the resource block is removed from the config.Fixes #1269
Type of change
How Has This Been Tested?
go test ./ovh/ -run TestResourceCloudProjectDelete_deletionProtection -vUnit test that verifies:
deletion_protection = trueblocks deletion with an appropriate error messagedeletion_protection = falsepasses the guard and proceeds to the API callAdditionally, manual testing was performed with a real cloud project:
deletion_protection = trueterraform destroyfails with errordeletion_protection = false, ranterraform applyterraform destroyproceedsTest Configuration:
Checklist:
go mod vendorif I added or modifygo.modfile