From 06dbd33113607b86ccc209c28352b6731107d52e Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Mon, 3 Jun 2024 16:42:10 +0800 Subject: [PATCH 1/8] azurerm_backup_policy_vm - support tiering_policy --- .../backup_policy_vm_resource.go | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index bdfd54eedcf0..4048e449e4df 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -853,6 +853,51 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { ValidateFunc: validate.RecoveryServicesVaultName, }, + // `tiering_policy` is defined as the map type in Swagger and currently the key only supports `ArchivedRP`. Service team confirmed that they would support other keys in the future. + "tiering_policy": { + Type: pluginsdk.TypeList, + MaxItems: 1, + Optional: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "archived_rp": { + Type: pluginsdk.TypeList, + MaxItems: 1, + Required: true, + Elem: &pluginsdk.Resource{ + Schema: map[string]*pluginsdk.Schema{ + "duration": { + Type: pluginsdk.TypeInt, + Optional: true, + ValidateFunc: validation.IntBetween(3, 1182), + }, + + "duration_type": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(protectionpolicies.RetentionDurationTypeDays), + string(protectionpolicies.RetentionDurationTypeWeeks), + string(protectionpolicies.RetentionDurationTypeMonths), + string(protectionpolicies.RetentionDurationTypeYears), + }, false), + }, + + "tiering_mode": { + Type: pluginsdk.TypeString, + Optional: true, + ValidateFunc: validation.StringInSlice([]string{ + string(protectionpolicies.TieringModeTierAfter), + string(protectionpolicies.TieringModeTierRecommended), + }, false), + }, + }, + }, + }, + }, + }, + }, + "timezone": { Type: pluginsdk.TypeString, Optional: true, From 38fffb225dc7a66e1617d083a12cd9072ad4372a Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Tue, 4 Jun 2024 12:43:12 +0800 Subject: [PATCH 2/8] azurerm_backup_policy_vm - support tiering_policy --- .../backup_policy_vm_resource.go | 63 +++++++++++++++++++ .../backup_policy_vm_resource_test.go | 59 +++++++++++++++++ website/docs/r/backup_policy_vm.html.markdown | 10 +++ 3 files changed, 132 insertions(+) diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index 4048e449e4df..780c45d1f82f 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -149,6 +149,7 @@ func resourceBackupProtectionPolicyVMCreateUpdate(d *pluginsdk.ResourceData, met TimeZone: utils.String(d.Get("timezone").(string)), PolicyType: pointer.To(policyType), SchedulePolicy: schedulePolicy, + TieringPolicy: expandBackupProtectionPolicyVMTieringPolicy(d.Get("tiering_policy").([]interface{})), InstantRPDetails: expandBackupProtectionPolicyVMResourceGroup(d), RetentionPolicy: &protectionpolicies.LongTermRetentionPolicy{ // SimpleRetentionPolicy only has duration property ¯\_(ツ)_/¯ DailySchedule: expandBackupProtectionPolicyVMRetentionDaily(d, times), @@ -214,6 +215,7 @@ func resourceBackupProtectionPolicyVMRead(d *pluginsdk.ResourceData, meta interf if properties, ok := model.Properties.(protectionpolicies.AzureIaaSVMProtectionPolicy); ok { d.Set("timezone", properties.TimeZone) d.Set("instant_restore_retention_days", properties.InstantRpRetentionRangeInDays) + d.Set("tiering_policy", flattenBackupProtectionPolicyVMTieringPolicy(properties.TieringPolicy)) if schedule, ok := properties.SchedulePolicy.(protectionpolicies.SimpleSchedulePolicy); ok { if err := d.Set("backup", flattenBackupProtectionPolicyVMSchedule(schedule)); err != nil { @@ -564,6 +566,35 @@ func expandBackupProtectionPolicyVMRetentionDailyFormat(block map[string]interfa return &daily } +func expandBackupProtectionPolicyVMTieringPolicy(input []interface{}) *map[string]protectionpolicies.TieringPolicy { + result := make(map[string]protectionpolicies.TieringPolicy) + if len(input) == 0 { + return &result + } + + tieringPolicy := input[0].(map[string]interface{}) + archivedRP := tieringPolicy["archived_rp"].([]interface{}) + result["ArchivedRP"] = expandBackupProtectionPolicyVMArchivedRP(archivedRP) + + return &result +} + +func expandBackupProtectionPolicyVMArchivedRP(input []interface{}) protectionpolicies.TieringPolicy { + if len(input) == 0 || input[0] == nil { + return protectionpolicies.TieringPolicy{} + } + + archivedRP := input[0].(map[string]interface{}) + + result := protectionpolicies.TieringPolicy{ + Duration: pointer.To(int64(archivedRP["duration"].(int))), + DurationType: pointer.To(protectionpolicies.RetentionDurationType(archivedRP["duration_type"].(string))), + TieringMode: pointer.To(protectionpolicies.TieringMode(archivedRP["tiering_mode"].(string))), + } + + return result +} + func flattenBackupProtectionPolicyVMResourceGroup(rpDetail protectionpolicies.InstantRPAdditionalDetails) []interface{} { if rpDetail.AzureBackupRGNamePrefix == nil { return nil @@ -769,6 +800,35 @@ func flattenBackupProtectionPolicyVMRetentionDailyFormat(retention *protectionpo return days, includeLastDay } +func flattenBackupProtectionPolicyVMTieringPolicy(input *map[string]protectionpolicies.TieringPolicy) []interface{} { + results := make([]interface{}, 0) + if input == nil { + return results + } + + for k, v := range *input { + if k == "ArchivedRP" { + results = append(results, map[string]interface{}{ + "archived_rp": flattenBackupProtectionPolicyVMArchivedRP(v), + }) + } + } + + return results +} + +func flattenBackupProtectionPolicyVMArchivedRP(input protectionpolicies.TieringPolicy) []interface{} { + results := make([]interface{}, 0) + + results = append(results, map[string]interface{}{ + "duration": int(pointer.From(input.Duration)), + "duration_type": string(pointer.From(input.DurationType)), + "tiering_mode": string(pointer.From(input.TieringMode)), + }) + + return results +} + func resourceBackupProtectionPolicyVMWaitForUpdate(ctx context.Context, client *protectionpolicies.ProtectionPoliciesClient, id protectionpolicies.BackupPolicyId, d *pluginsdk.ResourceData) error { state := &pluginsdk.StateChangeConf{ MinTimeout: 30 * time.Second, @@ -870,6 +930,7 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Type: pluginsdk.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(3, 1182), + AtLeastOneOf: []string{"tiering_policy.0.archived_rp.0.duration", "tiering_policy.0.archived_rp.0.duration_type", "tiering_policy.0.archived_rp.0.tiering_mode"}, }, "duration_type": { @@ -881,6 +942,7 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { string(protectionpolicies.RetentionDurationTypeMonths), string(protectionpolicies.RetentionDurationTypeYears), }, false), + AtLeastOneOf: []string{"tiering_policy.0.archived_rp.0.duration", "tiering_policy.0.archived_rp.0.duration_type", "tiering_policy.0.archived_rp.0.tiering_mode"}, }, "tiering_mode": { @@ -890,6 +952,7 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { string(protectionpolicies.TieringModeTierAfter), string(protectionpolicies.TieringModeTierRecommended), }, false), + AtLeastOneOf: []string{"tiering_policy.0.archived_rp.0.duration", "tiering_policy.0.archived_rp.0.duration_type", "tiering_policy.0.archived_rp.0.tiering_mode"}, }, }, }, diff --git a/internal/services/recoveryservices/backup_policy_vm_resource_test.go b/internal/services/recoveryservices/backup_policy_vm_resource_test.go index 49ce769e615a..450ca009eee0 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource_test.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource_test.go @@ -578,6 +578,21 @@ func TestAccBackupProtectionPolicyVM_completeDays(t *testing.T) { }) } +func TestAccBackupProtectionPolicyVM_tieringPolicy(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_backup_policy_vm", "test") + r := BackupProtectionPolicyVMResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.tieringPolicy(data), + Check: acceptance.ComposeAggregateTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + ), + }, + data.ImportStep(), + }) +} + func (t BackupProtectionPolicyVMResource) Exists(ctx context.Context, clients *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { id, err := protectionpolicies.ParseBackupPolicyID(state.ID) if err != nil { @@ -1007,3 +1022,47 @@ resource "azurerm_backup_policy_vm" "test" { } `, r.template(data), data.RandomInteger) } + +func (r BackupProtectionPolicyVMResource) tieringPolicy(data acceptance.TestData) string { + return fmt.Sprintf(` +%s + +resource "azurerm_backup_policy_vm" "test" { + name = "acctest-bpvm-%d" + resource_group_name = azurerm_resource_group.test.name + recovery_vault_name = azurerm_recovery_services_vault.test.name + + backup { + frequency = "Weekly" + time = "23:00" + weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"] + } + + retention_weekly { + count = 42 + weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"] + } + + retention_monthly { + count = 7 + weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"] + weeks = ["First", "Last"] + } + + retention_yearly { + count = 77 + weekdays = ["Sunday", "Wednesday", "Friday", "Saturday"] + weeks = ["First", "Last"] + months = ["January", "July"] + } + + tiering_policy { + archived_rp { + duration = 5 + duration_type = "Months" + tiering_mode = "TierAfter" + } + } +} +`, r.template(data), data.RandomInteger) +} diff --git a/website/docs/r/backup_policy_vm.html.markdown b/website/docs/r/backup_policy_vm.html.markdown index 108b2c0f3979..5504e13301ba 100644 --- a/website/docs/r/backup_policy_vm.html.markdown +++ b/website/docs/r/backup_policy_vm.html.markdown @@ -91,6 +91,8 @@ The following arguments are supported: * `retention_yearly` - (Optional) Configures the policy yearly retention as documented in the `retention_yearly` block below. +* `tiering_policy` - (Optional) A `tiering_policy` block as defined below. + --- The `backup` block supports: @@ -166,6 +168,14 @@ The `retention_yearly` block supports: --- +An `tiering_policy` block supports the following: + +* `duration` - (Optional) The number of days/weeks/months/years to retain backups in current tier before tiering. Possible values is between `3` and `1182`. + +* `duration_type` - (Optional) The retention duration type. Possible values are `Days`, `Weeks`, `Months` and `Years`. + +* `tiering_mode` - (Optional) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. + ## Attributes Reference In addition to the Arguments listed above - the following Attributes are exported: From 203c24d2946de6826c0ccfdbf874e54f93ec97da Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Tue, 4 Jun 2024 13:26:55 +0800 Subject: [PATCH 3/8] mark tier_mode as required --- .../backup_policy_vm_resource.go | 23 ++++++++----------- website/docs/r/backup_policy_vm.html.markdown | 4 ++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index 780c45d1f82f..81c28c28c54e 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -580,7 +580,7 @@ func expandBackupProtectionPolicyVMTieringPolicy(input []interface{}) *map[strin } func expandBackupProtectionPolicyVMArchivedRP(input []interface{}) protectionpolicies.TieringPolicy { - if len(input) == 0 || input[0] == nil { + if len(input) == 0 { return protectionpolicies.TieringPolicy{} } @@ -926,11 +926,19 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Required: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ + "tiering_mode": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringInSlice([]string{ + string(protectionpolicies.TieringModeTierAfter), + string(protectionpolicies.TieringModeTierRecommended), + }, false), + }, + "duration": { Type: pluginsdk.TypeInt, Optional: true, ValidateFunc: validation.IntBetween(3, 1182), - AtLeastOneOf: []string{"tiering_policy.0.archived_rp.0.duration", "tiering_policy.0.archived_rp.0.duration_type", "tiering_policy.0.archived_rp.0.tiering_mode"}, }, "duration_type": { @@ -942,17 +950,6 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { string(protectionpolicies.RetentionDurationTypeMonths), string(protectionpolicies.RetentionDurationTypeYears), }, false), - AtLeastOneOf: []string{"tiering_policy.0.archived_rp.0.duration", "tiering_policy.0.archived_rp.0.duration_type", "tiering_policy.0.archived_rp.0.tiering_mode"}, - }, - - "tiering_mode": { - Type: pluginsdk.TypeString, - Optional: true, - ValidateFunc: validation.StringInSlice([]string{ - string(protectionpolicies.TieringModeTierAfter), - string(protectionpolicies.TieringModeTierRecommended), - }, false), - AtLeastOneOf: []string{"tiering_policy.0.archived_rp.0.duration", "tiering_policy.0.archived_rp.0.duration_type", "tiering_policy.0.archived_rp.0.tiering_mode"}, }, }, }, diff --git a/website/docs/r/backup_policy_vm.html.markdown b/website/docs/r/backup_policy_vm.html.markdown index 5504e13301ba..b2557635c1ab 100644 --- a/website/docs/r/backup_policy_vm.html.markdown +++ b/website/docs/r/backup_policy_vm.html.markdown @@ -170,12 +170,12 @@ The `retention_yearly` block supports: An `tiering_policy` block supports the following: +* `tiering_mode` - (Required) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. + * `duration` - (Optional) The number of days/weeks/months/years to retain backups in current tier before tiering. Possible values is between `3` and `1182`. * `duration_type` - (Optional) The retention duration type. Possible values are `Days`, `Weeks`, `Months` and `Years`. -* `tiering_mode` - (Optional) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. - ## Attributes Reference In addition to the Arguments listed above - the following Attributes are exported: From 7c8bc42c851d0d43c9009310c0e97c1ef631e41b Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 7 Jun 2024 13:04:57 +0800 Subject: [PATCH 4/8] update resource --- .../backup_policy_vm_resource.go | 41 +++++++++++++++---- website/docs/r/backup_policy_vm.html.markdown | 2 +- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index 81c28c28c54e..c273b70b2395 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -569,6 +569,12 @@ func expandBackupProtectionPolicyVMRetentionDailyFormat(block map[string]interfa func expandBackupProtectionPolicyVMTieringPolicy(input []interface{}) *map[string]protectionpolicies.TieringPolicy { result := make(map[string]protectionpolicies.TieringPolicy) if len(input) == 0 { + result["ArchivedRP"] = protectionpolicies.TieringPolicy{ + TieringMode: pointer.To(protectionpolicies.TieringModeDoNotTier), + DurationType: pointer.To(protectionpolicies.RetentionDurationTypeInvalid), + Duration: pointer.To(int64(0)), + } + return &result } @@ -587,9 +593,15 @@ func expandBackupProtectionPolicyVMArchivedRP(input []interface{}) protectionpol archivedRP := input[0].(map[string]interface{}) result := protectionpolicies.TieringPolicy{ - Duration: pointer.To(int64(archivedRP["duration"].(int))), - DurationType: pointer.To(protectionpolicies.RetentionDurationType(archivedRP["duration_type"].(string))), - TieringMode: pointer.To(protectionpolicies.TieringMode(archivedRP["tiering_mode"].(string))), + TieringMode: pointer.To(protectionpolicies.TieringMode(archivedRP["tiering_mode"].(string))), + } + + if v := archivedRP["duration_type"].(string); v != "" { + result.DurationType = pointer.To(protectionpolicies.RetentionDurationType(v)) + } + + if v := archivedRP["duration"].(int); v != 0 { + result.Duration = pointer.To(int64(v)) } return result @@ -808,6 +820,10 @@ func flattenBackupProtectionPolicyVMTieringPolicy(input *map[string]protectionpo for k, v := range *input { if k == "ArchivedRP" { + if pointer.From(v.TieringMode) == protectionpolicies.TieringModeDoNotTier && pointer.From(v.DurationType) == protectionpolicies.RetentionDurationTypeInvalid && pointer.From(v.Duration) == 0 { + return results + } + results = append(results, map[string]interface{}{ "archived_rp": flattenBackupProtectionPolicyVMArchivedRP(v), }) @@ -820,11 +836,18 @@ func flattenBackupProtectionPolicyVMTieringPolicy(input *map[string]protectionpo func flattenBackupProtectionPolicyVMArchivedRP(input protectionpolicies.TieringPolicy) []interface{} { results := make([]interface{}, 0) - results = append(results, map[string]interface{}{ - "duration": int(pointer.From(input.Duration)), - "duration_type": string(pointer.From(input.DurationType)), - "tiering_mode": string(pointer.From(input.TieringMode)), - }) + result := map[string]interface{}{ + "tiering_mode": string(pointer.From(input.TieringMode)), + "duration": int(pointer.From(input.Duration)), + } + + durationType := "" + if v := input.DurationType; v != nil && pointer.From(v) != protectionpolicies.RetentionDurationTypeInvalid { + durationType = string(pointer.From(v)) + } + result["duration_type"] = durationType + + results = append(results, result) return results } @@ -938,7 +961,7 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { "duration": { Type: pluginsdk.TypeInt, Optional: true, - ValidateFunc: validation.IntBetween(3, 1182), + ValidateFunc: validation.IntAtLeast(3), }, "duration_type": { diff --git a/website/docs/r/backup_policy_vm.html.markdown b/website/docs/r/backup_policy_vm.html.markdown index b2557635c1ab..4f2494982036 100644 --- a/website/docs/r/backup_policy_vm.html.markdown +++ b/website/docs/r/backup_policy_vm.html.markdown @@ -172,7 +172,7 @@ An `tiering_policy` block supports the following: * `tiering_mode` - (Required) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. -* `duration` - (Optional) The number of days/weeks/months/years to retain backups in current tier before tiering. Possible values is between `3` and `1182`. +* `duration` - (Optional) The number of days/weeks/months/years to retain backups in current tier before tiering. * `duration_type` - (Optional) The retention duration type. Possible values are `Days`, `Weeks`, `Months` and `Years`. From a99e06d7e2b43569daf0d751cca519aeae697e5a Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Fri, 7 Jun 2024 15:00:28 +0800 Subject: [PATCH 5/8] update md --- website/docs/r/backup_policy_vm.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/backup_policy_vm.html.markdown b/website/docs/r/backup_policy_vm.html.markdown index 4f2494982036..c03fbdf6e7d0 100644 --- a/website/docs/r/backup_policy_vm.html.markdown +++ b/website/docs/r/backup_policy_vm.html.markdown @@ -168,7 +168,7 @@ The `retention_yearly` block supports: --- -An `tiering_policy` block supports the following: +A `tiering_policy` block supports the following: * `tiering_mode` - (Required) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. From 1eea1cb477817737c9125b0cfd4b927a22614cb3 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 12 Jun 2024 09:33:40 +0800 Subject: [PATCH 6/8] rename tiering_mode to mode --- .../recoveryservices/backup_policy_vm_resource.go | 8 ++++---- .../recoveryservices/backup_policy_vm_resource_test.go | 2 +- website/docs/r/backup_policy_vm.html.markdown | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index c273b70b2395..ee72caf0681d 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -593,7 +593,7 @@ func expandBackupProtectionPolicyVMArchivedRP(input []interface{}) protectionpol archivedRP := input[0].(map[string]interface{}) result := protectionpolicies.TieringPolicy{ - TieringMode: pointer.To(protectionpolicies.TieringMode(archivedRP["tiering_mode"].(string))), + TieringMode: pointer.To(protectionpolicies.TieringMode(archivedRP["mode"].(string))), } if v := archivedRP["duration_type"].(string); v != "" { @@ -837,8 +837,8 @@ func flattenBackupProtectionPolicyVMArchivedRP(input protectionpolicies.TieringP results := make([]interface{}, 0) result := map[string]interface{}{ - "tiering_mode": string(pointer.From(input.TieringMode)), - "duration": int(pointer.From(input.Duration)), + "mode": string(pointer.From(input.TieringMode)), + "duration": int(pointer.From(input.Duration)), } durationType := "" @@ -949,7 +949,7 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Required: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "tiering_mode": { + "mode": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringInSlice([]string{ diff --git a/internal/services/recoveryservices/backup_policy_vm_resource_test.go b/internal/services/recoveryservices/backup_policy_vm_resource_test.go index 450ca009eee0..16845ef06a9e 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource_test.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource_test.go @@ -1060,7 +1060,7 @@ resource "azurerm_backup_policy_vm" "test" { archived_rp { duration = 5 duration_type = "Months" - tiering_mode = "TierAfter" + mode = "TierAfter" } } } diff --git a/website/docs/r/backup_policy_vm.html.markdown b/website/docs/r/backup_policy_vm.html.markdown index c03fbdf6e7d0..fc3a825170b4 100644 --- a/website/docs/r/backup_policy_vm.html.markdown +++ b/website/docs/r/backup_policy_vm.html.markdown @@ -170,7 +170,7 @@ The `retention_yearly` block supports: A `tiering_policy` block supports the following: -* `tiering_mode` - (Required) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. +* `mode` - (Required) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. * `duration` - (Optional) The number of days/weeks/months/years to retain backups in current tier before tiering. From c23c3e152831c5ebc2849ac97f50f4d3977ccf6f Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Wed, 12 Jun 2024 09:43:44 +0800 Subject: [PATCH 7/8] update md for archived_rp --- website/docs/r/backup_policy_vm.html.markdown | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/website/docs/r/backup_policy_vm.html.markdown b/website/docs/r/backup_policy_vm.html.markdown index fc3a825170b4..0a7d3d652d4e 100644 --- a/website/docs/r/backup_policy_vm.html.markdown +++ b/website/docs/r/backup_policy_vm.html.markdown @@ -170,6 +170,12 @@ The `retention_yearly` block supports: A `tiering_policy` block supports the following: +* `archived_rp` - (Required) An `archived_rp` block as defined below. + +--- + +An `archived_rp` block supports the following: + * `mode` - (Required) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`. * `duration` - (Optional) The number of days/weeks/months/years to retain backups in current tier before tiering. From 054523237cf054ddd65d9c0616554abcf7d1730b Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Thu, 20 Jun 2024 14:26:14 +0800 Subject: [PATCH 8/8] rename to archived_restore_point --- .../services/recoveryservices/backup_policy_vm_resource.go | 6 +++--- .../recoveryservices/backup_policy_vm_resource_test.go | 2 +- website/docs/r/backup_policy_vm.html.markdown | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/services/recoveryservices/backup_policy_vm_resource.go b/internal/services/recoveryservices/backup_policy_vm_resource.go index ee72caf0681d..1b39e30a01c2 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource.go @@ -579,7 +579,7 @@ func expandBackupProtectionPolicyVMTieringPolicy(input []interface{}) *map[strin } tieringPolicy := input[0].(map[string]interface{}) - archivedRP := tieringPolicy["archived_rp"].([]interface{}) + archivedRP := tieringPolicy["archived_restore_point"].([]interface{}) result["ArchivedRP"] = expandBackupProtectionPolicyVMArchivedRP(archivedRP) return &result @@ -825,7 +825,7 @@ func flattenBackupProtectionPolicyVMTieringPolicy(input *map[string]protectionpo } results = append(results, map[string]interface{}{ - "archived_rp": flattenBackupProtectionPolicyVMArchivedRP(v), + "archived_restore_point": flattenBackupProtectionPolicyVMArchivedRP(v), }) } } @@ -943,7 +943,7 @@ func resourceBackupProtectionPolicyVMSchema() map[string]*pluginsdk.Schema { Optional: true, Elem: &pluginsdk.Resource{ Schema: map[string]*pluginsdk.Schema{ - "archived_rp": { + "archived_restore_point": { Type: pluginsdk.TypeList, MaxItems: 1, Required: true, diff --git a/internal/services/recoveryservices/backup_policy_vm_resource_test.go b/internal/services/recoveryservices/backup_policy_vm_resource_test.go index 16845ef06a9e..3915bb004a43 100644 --- a/internal/services/recoveryservices/backup_policy_vm_resource_test.go +++ b/internal/services/recoveryservices/backup_policy_vm_resource_test.go @@ -1057,7 +1057,7 @@ resource "azurerm_backup_policy_vm" "test" { } tiering_policy { - archived_rp { + archived_restore_point { duration = 5 duration_type = "Months" mode = "TierAfter" diff --git a/website/docs/r/backup_policy_vm.html.markdown b/website/docs/r/backup_policy_vm.html.markdown index 0a7d3d652d4e..bb4b16219075 100644 --- a/website/docs/r/backup_policy_vm.html.markdown +++ b/website/docs/r/backup_policy_vm.html.markdown @@ -170,11 +170,11 @@ The `retention_yearly` block supports: A `tiering_policy` block supports the following: -* `archived_rp` - (Required) An `archived_rp` block as defined below. +* `archived_restore_point` - (Required) An `archived_restore_point` block as defined below. --- -An `archived_rp` block supports the following: +An `archived_restore_point` block supports the following: * `mode` - (Required) The tiering mode to control automatic tiering of recovery points. Possible values are `TierAfter` and `TierRecommended`.