-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add Firestore deletion protection #8906
Merged
trodge
merged 6 commits into
GoogleCloudPlatform:main
from
simpleclub-extended:add-firestore-deletion-protection
Sep 15, 2023
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1c95044
Add Firestore deletion protection
IchordeDionysos cfe45af
Merge branch 'main' into add-firestore-deletion-protection
IchordeDionysos ca6b7ef
Reformat
IchordeDionysos 429573f
Add test for updating delete_protection_state
IchordeDionysos bdd9d9b
Make deleteProtectionState skip auto-generated tests
IchordeDionysos 5aac2e0
Add a dedicated example for delete protection
IchordeDionysos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this cause the database to not be deleted when the test completes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will prevent the database from being deletable!
Meaning with
delete_protection_state
set toDELETE_PROTECTION_ENABLED
this request would fail:While this request would succeed when the
delete_protection_state
is set toDELETE_PROTECTION_DISABLED
.--
https://cloud.google.com/firestore/docs/manage-databases#delete_protection
It behaves similarly to the Cloud SQL instance deletion protection: https://cloud.google.com/sql/docs/mysql/deletion-protection#rest-v1
Or the Google Cloud Project liens deletion protection: https://cloud.google.com/resource-manager/docs/project-liens
--
Setting, unsettling, or changing this field has no direct impact on the deletion of the database.
So, when you create a database with
delete_projection_state
set toDELETE_PROTECTION_ENABLED
, you can't remove that resource in a single change request/PR.You first have to set it to
DELETE_PROTECTION_DISABLED
and then you can remove the resource.This is useful to prevent accidental deletions of Firestore databases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case I think we'll want to use
skip_test
to prevent this test from being run and leaving behind databases in our test environment. We should rely on a handwritten test that removes deletion protection before completing so that the test databases can be cleaned up.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trodge that makes sense!
I'm wondering. I've already added a custom test that checks if updating works for that field!
https://github.com/GoogleCloudPlatform/magic-modules/pull/8906/files#diff-0f0af92ffe258bbd03d14d44b699ac64106de5d46fed4db170cb2c37ab5a8546R92-R120
And, as I understand it, that test
So that test should cover those cases already, no?
Is there anything else I should add to the tests?
Besides adding the
skip_test
flag to thedelete_protection_state
field?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trodge I've added the
skip_test
flag to the field.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skip_test
is an attribute of the example, not the field. We'll want to skip the example test because the update test already covers everything it covers and we don't want to leave orphaned resources.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@trodge sorry, misunderstood you there!
I did not want to skip the tests for
firestore_database
as a lot of other fields are being tested there.So I've removed the
delete_protection_state
field from this standard test and added a custom example (which is being skipped) for the delete protection.I took the opportunity to describe how to remove a database with delete protection enabled!