Skip to content

Change backupvault force-delete behavior: have two separate parameters for different deletion scenarios. #8616

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelog/12012.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
```release-note: deprecation
backupdr: deprecated `force_delete` on `google_backup_dr_backup_vault`. Use `ignore_inactive_datasources` instead (beta)
```
```release-note: enhancement
backupdr: added `ignore_inactive_datasources` and `ignore_backup_plan_references` fields to `google_backup_dr_backup_vault` resource (beta)
```
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ Please refer to the field 'effective_annotations' for all of the annotations pre
Description: `Optional. Time after which the BackupVault resource is locked.`,
},
"force_delete": {
Type: schema.TypeBool,
Optional: true,
Type: schema.TypeBool,
Optional: true,
Deprecated: "`force_delete` is deprecated and will be removed in a future major release. Use `ignore_inactive_datasources` instead.",
Description: `If set, the following restrictions against deletion of the backup vault instance can be overridden:
* deletion of a backup vault instance containing no backups, but still containing empty datasources.
* deletion of a backup vault instance that is being referenced by an active backup plan.`,
Default: false,
Default: false,
ConflictsWith: []string{},
},
"force_update": {
Type: schema.TypeBool,
Expand All @@ -116,6 +118,21 @@ Please refer to the field 'effective_annotations' for all of the annotations pre
retention set by the backup vault.`,
Default: false,
},
"ignore_backup_plan_references": {
Type: schema.TypeBool,
Optional: true,
Description: `If set, the following restrictions against deletion of the backup vault instance can be overridden:
* deletion of a backup vault instance that is being referenced by an active backup plan.`,
Default: false,
},
"ignore_inactive_datasources": {
Type: schema.TypeBool,
Optional: true,
Description: `If set, the following restrictions against deletion of the backup vault instance can be overridden:
* deletion of a backup vault instance containing no backups, but still containing empty datasources.`,
Default: false,
ConflictsWith: []string{},
},
"labels": {
Type: schema.TypeMap,
Optional: true,
Expand Down Expand Up @@ -553,7 +570,7 @@ func resourceBackupDRBackupVaultDelete(d *schema.ResourceData, meta interface{})
}
billingProject = project

url, err := tpgresource.ReplaceVars(d, config, "{{BackupDRBasePath}}projects/{{project}}/locations/{{location}}/backupVaults/{{backup_vault_id}}?force={{force_delete}}&allowMissing={{allow_missing}}")
url, err := tpgresource.ReplaceVars(d, config, "{{BackupDRBasePath}}projects/{{project}}/locations/{{location}}/backupVaults/{{backup_vault_id}}")
if err != nil {
return err
}
Expand All @@ -566,6 +583,30 @@ func resourceBackupDRBackupVaultDelete(d *schema.ResourceData, meta interface{})
}

headers := make(http.Header)
if v, ok := d.GetOk("ignore_inactive_datasources"); ok {
url, err = transport_tpg.AddQueryParams(url, map[string]string{"force": fmt.Sprintf("%v", v)})
if err != nil {
return err
}
}
if v, ok := d.GetOk("force_delete"); ok {
url, err = transport_tpg.AddQueryParams(url, map[string]string{"force": fmt.Sprintf("%v", v)})
if err != nil {
return err
}
}
if v, ok := d.GetOk("ignore_backup_plan_references"); ok {
url, err = transport_tpg.AddQueryParams(url, map[string]string{"ignoreBackupPlanReferences": fmt.Sprintf("%v", v)})
if err != nil {
return err
}
}
if v, ok := d.GetOk("allow_missing"); ok {
url, err = transport_tpg.AddQueryParams(url, map[string]string{"allowMissing": fmt.Sprintf("%v", v)})
if err != nil {
return err
}
}

log.Printf("[DEBUG] Deleting BackupVault %q", d.Id())
res, err := transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestAccBackupDRBackupVault_backupDrBackupVaultFullExample(t *testing.T) {
ResourceName: "google_backup_dr_backup_vault.backup-vault-test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "labels", "location", "terraform_labels"},
},
},
})
Expand All @@ -74,7 +74,8 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
annotations2 = "baz1"
}
force_update = "true"
force_delete = "true"
ignore_inactive_datasources = "true"
ignore_backup_plan_references = "true"
allow_missing = "true"
}
`, context)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestAccBackupDRBackupVault_fullUpdate(t *testing.T) {
ResourceName: "google_backup_dr_backup_vault.backup-vault-test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "labels", "location", "terraform_labels"},
},
{
Config: testAccBackupDRBackupVault_fullUpdate(context),
Expand All @@ -42,7 +42,7 @@ func TestAccBackupDRBackupVault_fullUpdate(t *testing.T) {
ResourceName: "google_backup_dr_backup_vault.backup-vault-test",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "labels", "location", "terraform_labels"},
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "labels", "location", "terraform_labels"},
},
},
})
Expand All @@ -66,7 +66,8 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
annotations2 = "baz"
}
force_update = "true"
force_delete = "true"
ignore_inactive_datasources = "true"
ignore_backup_plan_references = "true"
allow_missing = "true"
}
`, context)
Expand All @@ -90,7 +91,8 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
annotations2 = "baz1"
}
force_update = "true"
force_delete = "true"
ignore_inactive_datasources = "true"
ignore_backup_plan_references = "true"
allow_missing = "true"
}
`, context)
Expand Down
15 changes: 14 additions & 1 deletion website/docs/r/backup_dr_backup_vault.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
annotations2 = "baz1"
}
force_update = "true"
force_delete = "true"
ignore_inactive_datasources = "true"
ignore_backup_plan_references = "true"
allow_missing = "true"
}
```
Expand Down Expand Up @@ -99,9 +100,21 @@ The following arguments are supported:
retention set by the backup vault.

* `force_delete` -
(Optional, Deprecated)
If set, the following restrictions against deletion of the backup vault instance can be overridden:
* deletion of a backup vault instance containing no backups, but still containing empty datasources.
* deletion of a backup vault instance that is being referenced by an active backup plan.

~> **Warning:** `force_delete` is deprecated and will be removed in a future major release. Use `ignore_inactive_datasources` instead.

* `ignore_inactive_datasources` -
(Optional)
If set, the following restrictions against deletion of the backup vault instance can be overridden:
* deletion of a backup vault instance containing no backups, but still containing empty datasources.

* `ignore_backup_plan_references` -
(Optional)
If set, the following restrictions against deletion of the backup vault instance can be overridden:
* deletion of a backup vault instance that is being referenced by an active backup plan.

* `allow_missing` -
Expand Down