Skip to content

Commit 9bb03c5

Browse files
backupretentioninheritance (#14555) (#10446)
[upstream:56cda7716b782a0b0bb2a1903311b8cce85165c5] Signed-off-by: Modular Magician <[email protected]>
1 parent 18e9f33 commit 9bb03c5

File tree

6 files changed

+40
-3
lines changed

6 files changed

+40
-3
lines changed

.changelog/14555.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
unknown: backupretentioninheritance

google-beta/services/backupdr/resource_backup_dr_backup_vault.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ Stores small amounts of arbitrary data.
100100
Please refer to the field 'effective_annotations' for all of the annotations present on the resource.`,
101101
Elem: &schema.Schema{Type: schema.TypeString},
102102
},
103+
"backup_retention_inheritance": {
104+
Type: schema.TypeString,
105+
Optional: true,
106+
ValidateFunc: verify.ValidateEnum([]string{"BACKUP_RETENTION_INHERITANCE_UNSPECIFIED", "INHERIT_VAULT_RETENTION", "MATCH_BACKUP_EXPIRE_TIME", ""}),
107+
Description: `How a backup's enforced retention end time is inherited. Default value is 'INHERIT_VAULT_RETENTION' if not provided during creation. Possible values: ["BACKUP_RETENTION_INHERITANCE_UNSPECIFIED", "INHERIT_VAULT_RETENTION", "MATCH_BACKUP_EXPIRE_TIME"]`,
108+
},
103109
"description": {
104110
Type: schema.TypeString,
105111
Optional: true,
@@ -271,6 +277,12 @@ func resourceBackupDRBackupVaultCreate(d *schema.ResourceData, meta interface{})
271277
} else if v, ok := d.GetOkExists("access_restriction"); !tpgresource.IsEmptyValue(reflect.ValueOf(accessRestrictionProp)) && (ok || !reflect.DeepEqual(v, accessRestrictionProp)) {
272278
obj["accessRestriction"] = accessRestrictionProp
273279
}
280+
backupRetentionInheritanceProp, err := expandBackupDRBackupVaultBackupRetentionInheritance(d.Get("backup_retention_inheritance"), d, config)
281+
if err != nil {
282+
return err
283+
} else if v, ok := d.GetOkExists("backup_retention_inheritance"); !tpgresource.IsEmptyValue(reflect.ValueOf(backupRetentionInheritanceProp)) && (ok || !reflect.DeepEqual(v, backupRetentionInheritanceProp)) {
284+
obj["backupRetentionInheritance"] = backupRetentionInheritanceProp
285+
}
274286
labelsProp, err := expandBackupDRBackupVaultEffectiveLabels(d.Get("effective_labels"), d, config)
275287
if err != nil {
276288
return err
@@ -477,6 +489,12 @@ func resourceBackupDRBackupVaultUpdate(d *schema.ResourceData, meta interface{})
477489
} else if v, ok := d.GetOkExists("effective_time"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, effectiveTimeProp)) {
478490
obj["effectiveTime"] = effectiveTimeProp
479491
}
492+
backupRetentionInheritanceProp, err := expandBackupDRBackupVaultBackupRetentionInheritance(d.Get("backup_retention_inheritance"), d, config)
493+
if err != nil {
494+
return err
495+
} else if v, ok := d.GetOkExists("backup_retention_inheritance"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, backupRetentionInheritanceProp)) {
496+
obj["backupRetentionInheritance"] = backupRetentionInheritanceProp
497+
}
480498
labelsProp, err := expandBackupDRBackupVaultEffectiveLabels(d.Get("effective_labels"), d, config)
481499
if err != nil {
482500
return err
@@ -511,6 +529,10 @@ func resourceBackupDRBackupVaultUpdate(d *schema.ResourceData, meta interface{})
511529
updateMask = append(updateMask, "effectiveTime")
512530
}
513531

532+
if d.HasChange("backup_retention_inheritance") {
533+
updateMask = append(updateMask, "backupRetentionInheritance")
534+
}
535+
514536
if d.HasChange("effective_labels") {
515537
updateMask = append(updateMask, "labels")
516538
}
@@ -786,6 +808,10 @@ func expandBackupDRBackupVaultAccessRestriction(v interface{}, d tpgresource.Ter
786808
return v, nil
787809
}
788810

811+
func expandBackupDRBackupVaultBackupRetentionInheritance(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) {
812+
return v, nil
813+
}
814+
789815
func expandBackupDRBackupVaultEffectiveLabels(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (map[string]string, error) {
790816
if v == nil {
791817
return map[string]string{}, nil

google-beta/services/backupdr/resource_backup_dr_backup_vault_generated_meta.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fields:
1111
- field: 'annotations'
1212
- field: 'backup_count'
1313
- field: 'backup_minimum_enforced_retention_duration'
14+
- field: 'backup_retention_inheritance'
1415
- field: 'backup_vault_id'
1516
provider_only: true
1617
- field: 'create_time'

google-beta/services/backupdr/resource_backup_dr_backup_vault_generated_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func TestAccBackupDRBackupVault_backupDrBackupVaultFullExample(t *testing.T) {
5151
ResourceName: "google_backup_dr_backup_vault.backup-vault-test",
5252
ImportState: true,
5353
ImportStateVerify: true,
54-
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "labels", "location", "terraform_labels"},
54+
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_retention_inheritance", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "labels", "location", "terraform_labels"},
5555
},
5656
},
5757
})
@@ -74,6 +74,7 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
7474
}
7575
force_update = "true"
7676
access_restriction = "WITHIN_ORGANIZATION"
77+
backup_retention_inheritance = "INHERIT_VAULT_RETENTION"
7778
ignore_inactive_datasources = "true"
7879
ignore_backup_plan_references = "true"
7980
allow_missing = "true"

google-beta/services/backupdr/resource_backup_dr_backup_vault_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func TestAccBackupDRBackupVault_fullUpdate(t *testing.T) {
5050
ResourceName: "google_backup_dr_backup_vault.backup-vault-test",
5151
ImportState: true,
5252
ImportStateVerify: true,
53-
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "access_restriction", "labels", "location", "terraform_labels"},
53+
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "backup_retention_inheritance", "access_restriction", "labels", "location", "terraform_labels"},
5454
},
5555
{
5656
Config: testAccBackupDRBackupVault_fullUpdate(context),
@@ -59,7 +59,7 @@ func TestAccBackupDRBackupVault_fullUpdate(t *testing.T) {
5959
ResourceName: "google_backup_dr_backup_vault.backup-vault-test",
6060
ImportState: true,
6161
ImportStateVerify: true,
62-
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "access_restriction", "labels", "location", "terraform_labels"},
62+
ImportStateVerifyIgnore: []string{"allow_missing", "annotations", "backup_vault_id", "force_delete", "force_update", "ignore_backup_plan_references", "ignore_inactive_datasources", "backup_retention_inheritance", "access_restriction", "labels", "location", "terraform_labels"},
6363
},
6464
},
6565
})
@@ -84,6 +84,7 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
8484
force_update = "true"
8585
ignore_inactive_datasources = "true"
8686
access_restriction = "WITHIN_ORGANIZATION"
87+
backup_retention_inheritance = "INHERIT_VAULT_RETENTION"
8788
ignore_backup_plan_references = "true"
8889
allow_missing = "true"
8990
}
@@ -108,6 +109,7 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
108109
}
109110
force_update = "true"
110111
access_restriction = "WITHIN_ORGANIZATION"
112+
backup_retention_inheritance = "INHERIT_VAULT_RETENTION"
111113
ignore_inactive_datasources = "true"
112114
ignore_backup_plan_references = "true"
113115
allow_missing = "true"

website/docs/r/backup_dr_backup_vault.html.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ resource "google_backup_dr_backup_vault" "backup-vault-test" {
4444
}
4545
force_update = "true"
4646
access_restriction = "WITHIN_ORGANIZATION"
47+
backup_retention_inheritance = "INHERIT_VAULT_RETENTION"
4748
ignore_inactive_datasources = "true"
4849
ignore_backup_plan_references = "true"
4950
allow_missing = "true"
@@ -95,6 +96,11 @@ The following arguments are supported:
9596
Default value is `WITHIN_ORGANIZATION`.
9697
Possible values are: `ACCESS_RESTRICTION_UNSPECIFIED`, `WITHIN_PROJECT`, `WITHIN_ORGANIZATION`, `UNRESTRICTED`, `WITHIN_ORG_BUT_UNRESTRICTED_FOR_BA`.
9798

99+
* `backup_retention_inheritance` -
100+
(Optional)
101+
How a backup's enforced retention end time is inherited. Default value is `INHERIT_VAULT_RETENTION` if not provided during creation.
102+
Possible values are: `BACKUP_RETENTION_INHERITANCE_UNSPECIFIED`, `INHERIT_VAULT_RETENTION`, `MATCH_BACKUP_EXPIRE_TIME`.
103+
98104
* `force_update` -
99105
(Optional)
100106
If set, allow update to extend the minimum enforced retention for backup vault. This overrides

0 commit comments

Comments
 (0)