From 08230fbacbceac79f41600b42d9256f05653ad02 Mon Sep 17 00:00:00 2001 From: Matthew Date: Mon, 24 Jul 2023 15:58:35 -0700 Subject: [PATCH] azurerm_redis_cache - only update patch_schedule when it has changed in the config file --- .../services/redis/redis_cache_resource.go | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/internal/services/redis/redis_cache_resource.go b/internal/services/redis/redis_cache_resource.go index 013daef7937b..ad1cb7445c13 100644 --- a/internal/services/redis/redis_cache_resource.go +++ b/internal/services/redis/redis_cache_resource.go @@ -601,18 +601,20 @@ func resourceRedisCacheUpdate(d *pluginsdk.ResourceData, meta interface{}) error } } - patchSchedule := expandRedisPatchSchedule(d) + if d.HasChange("patch_schedule") { + patchSchedule := expandRedisPatchSchedule(d) - patchSchedulesRedisId := patchschedules.NewRediID(id.SubscriptionId, id.ResourceGroupName, id.RedisName) - if patchSchedule == nil || len(patchSchedule.Properties.ScheduleEntries) == 0 { - _, err = patchClient.Delete(ctx, patchSchedulesRedisId) - if err != nil { - return fmt.Errorf("deleting Patch Schedule for %s: %+v", *id, err) - } - } else { - _, err = patchClient.CreateOrUpdate(ctx, patchSchedulesRedisId, *patchSchedule) - if err != nil { - return fmt.Errorf("setting Patch Schedule for %s: %+v", *id, err) + patchSchedulesRedisId := patchschedules.NewRediID(id.SubscriptionId, id.ResourceGroupName, id.RedisName) + if patchSchedule == nil || len(patchSchedule.Properties.ScheduleEntries) == 0 { + _, err = patchClient.Delete(ctx, patchSchedulesRedisId) + if err != nil { + return fmt.Errorf("deleting Patch Schedule for %s: %+v", *id, err) + } + } else { + _, err = patchClient.CreateOrUpdate(ctx, patchSchedulesRedisId, *patchSchedule) + if err != nil { + return fmt.Errorf("setting Patch Schedule for %s: %+v", *id, err) + } } }