From 4e408b453a1cd521fece8c8ff08f12bc411a1096 Mon Sep 17 00:00:00 2001 From: neil-yechenwei Date: Mon, 5 Jul 2021 14:15:41 +0800 Subject: [PATCH] Add support for the of azurerm_redis_cache --- .../services/redis/redis_cache_resource.go | 16 ++++++++++++++-- .../services/redis/redis_cache_resource_test.go | 5 +++-- website/docs/r/redis_cache.html.markdown | 2 ++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/redis/redis_cache_resource.go b/azurerm/internal/services/redis/redis_cache_resource.go index 5c5492f62acd..f0771a29c982 100644 --- a/azurerm/internal/services/redis/redis_cache_resource.go +++ b/azurerm/internal/services/redis/redis_cache_resource.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/go-azure-helpers/response" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" + azValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/location" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/locks" @@ -223,6 +224,14 @@ func resourceRedisCache() *pluginsdk.Resource { DiffSuppressFunc: suppress.CaseDifference, ValidateFunc: validation.IsDayOfTheWeek(true), }, + + "maintenance_window": { + Type: pluginsdk.TypeString, + Optional: true, + Default: "PT5H", + ValidateFunc: azValidate.ISO8601Duration, + }, + "start_hour_utc": { Type: pluginsdk.TypeInt, Optional: true, @@ -746,11 +755,13 @@ func expandRedisPatchSchedule(d *pluginsdk.ResourceData) *redis.PatchSchedule { for _, scheduleValue := range scheduleValues { vals := scheduleValue.(map[string]interface{}) dayOfWeek := vals["day_of_week"].(string) + maintenanceWindow := vals["maintenance_window"].(string) startHourUtc := vals["start_hour_utc"].(int) entry := redis.ScheduleEntry{ - DayOfWeek: redis.DayOfWeek(dayOfWeek), - StartHourUtc: utils.Int32(int32(startHourUtc)), + DayOfWeek: redis.DayOfWeek(dayOfWeek), + MaintenanceWindow: utils.String(maintenanceWindow), + StartHourUtc: utils.Int32(int32(startHourUtc)), } entries = append(entries, entry) } @@ -875,6 +886,7 @@ func flattenRedisPatchSchedules(schedule redis.PatchSchedule) []interface{} { output := make(map[string]interface{}) output["day_of_week"] = string(entry.DayOfWeek) + output["maintenance_window"] = *entry.MaintenanceWindow output["start_hour_utc"] = int(*entry.StartHourUtc) outputs = append(outputs, output) diff --git a/azurerm/internal/services/redis/redis_cache_resource_test.go b/azurerm/internal/services/redis/redis_cache_resource_test.go index 8b49749321c4..9dc860c06126 100644 --- a/azurerm/internal/services/redis/redis_cache_resource_test.go +++ b/azurerm/internal/services/redis/redis_cache_resource_test.go @@ -781,8 +781,9 @@ resource "azurerm_redis_cache" "test" { } patch_schedule { - day_of_week = "Tuesday" - start_hour_utc = 8 + day_of_week = "Tuesday" + start_hour_utc = 8 + maintenance_window = "PT7H" } } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) diff --git a/website/docs/r/redis_cache.html.markdown b/website/docs/r/redis_cache.html.markdown index b6bde38a213b..1a2d60d174e1 100644 --- a/website/docs/r/redis_cache.html.markdown +++ b/website/docs/r/redis_cache.html.markdown @@ -160,6 +160,8 @@ A `patch_schedule` block supports the following: ~> **Note:** The Patch Window lasts for `5` hours from the `start_hour_utc`. +* `maintenance_window` - (Optional) The ISO 8601 timespan which specifies the amount of time the Redis Cache can be updated. Defaults to `PT5H`. + ## Attributes Reference The following attributes are exported: