Skip to content

Commit

Permalink
azurerm_redis_cache: support the maintenance_window property (#12472)
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Ye authored Jul 14, 2021
1 parent 257bf1e commit 39b0e76
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
16 changes: 14 additions & 2 deletions azurerm/internal/services/redis/redis_cache_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions azurerm/internal/services/redis/redis_cache_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/redis_cache.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 39b0e76

Please sign in to comment.