Skip to content
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

Add support for the maintenanceWindow property of azurerm_redis_cache #12472

Merged
merged 1 commit into from
Jul 14, 2021
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
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