feat(cloudsql-instance): expose retain_backups_on_delete#27
Merged
Calvin-Cheng1 merged 2 commits intoMay 8, 2026
Merged
Conversation
Adds an optional retain_backups_on_delete variable (default true, the provider default) wired into both the primary instance and read replicas. This lets users decide whether automated and on-demand backups should be preserved when the instance is destroyed, which is often desirable for recoverability and for meeting data-retention requirements even when the instance itself is being torn down. Made-with: Cursor
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Collaborator
Calvin-Cheng1
left a comment
There was a problem hiding this comment.
Would prefer to handle this logic on the already existing variable: "backup_configuration" there is a strong reason not to
Contributor
Author
Great idea! I did that, and updated the Readme too |
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.
What
Exposes the
settings.retain_backups_on_deleteattribute ongoogle_sql_database_instanceas a new field on the existingbackup_configurationmodule variable:and wires it into the
settings {}block of bothgoogle_sql_database_instance.primaryandgoogle_sql_database_instance.replicas.Why
When a Cloud SQL instance is deleted, this flag controls whether its automated and on-demand backups are kept afterwards. There is no way to set it through the module today, so users who want the non-default behaviour (drop backups on delete, e.g. for short-lived preview / PR environments) have to either delete the backups manually from the console / API after destroy, or fork the module.
It belongs on
backup_configurationrather than as a sibling top-level variable: every other knob that decides what happens to backups (enabled,point_in_time_recovery_enabled,retention_count,log_retention_days, …) already lives there, so users only have one place to look when they're reasoning about backup behaviour. Keeping it next toretention_countin particular makes the relationship between "how many backups we keep while the instance is alive" and "what happens to those backups when the instance is destroyed" obvious.Compatibility
default = true, which matches the current GCP default and what Terraform gets today when the attribute isn't set by the module. Existing callers see no planned diff.false) flips both in one place, which is almost always what users want.tools/tfdoc.py; this also removes a stale "Fixtures" entry that referenced a non-existent fixture file (unrelated cleanup, surfaced by re-running the doc generator).