diff --git a/internal/services/redis/redis_cache_resource.go b/internal/services/redis/redis_cache_resource.go index c14db6b517cb..5a2b81736e51 100644 --- a/internal/services/redis/redis_cache_resource.go +++ b/internal/services/redis/redis_cache_resource.go @@ -386,12 +386,12 @@ func resourceRedisCache() *pluginsdk.Resource { // Entra (AD) auth has to be set to disable access keys auth // https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-azure-active-directory-for-authentication - accessKeysAuthenticationDisabled := !(diff.Get("access_keys_authentication_enabled").(bool)) + accessKeysAuthenticationEnabled := diff.Get("access_keys_authentication_enabled").(bool) activeDirectoryAuthenticationEnabled := diff.Get("redis_configuration.0.active_directory_authentication_enabled").(bool) - log.Printf("[DEBUG] CustomizeDiff: access_keys_authentication_enabled: %v, active_directory_authentication_enabled: %v", accessKeysAuthenticationDisabled, activeDirectoryAuthenticationEnabled) + log.Printf("[DEBUG] CustomizeDiff: access_keys_authentication_enabled: %v, active_directory_authentication_enabled: %v", accessKeysAuthenticationEnabled, activeDirectoryAuthenticationEnabled) - if accessKeysAuthenticationDisabled && !activeDirectoryAuthenticationEnabled { + if !accessKeysAuthenticationEnabled && !activeDirectoryAuthenticationEnabled { return fmt.Errorf("`active_directory_authentication_enabled` must be enabled in order to disable `access_keys_authentication_enabled`") } @@ -860,7 +860,11 @@ func resourceRedisCacheRead(d *pluginsdk.ResourceData, meta interface{}) error { d.Set("primary_access_key", keysResp.Model.PrimaryKey) d.Set("secondary_access_key", keysResp.Model.SecondaryKey) - d.Set("access_keys_authentication_enabled", !(*props.DisableAccessKeyAuthentication)) + accessKeyAuthEnabled := true + if props.DisableAccessKeyAuthentication != nil { + accessKeyAuthEnabled = !(*props.DisableAccessKeyAuthentication) + } + d.Set("access_keys_authentication_enabled", accessKeyAuthEnabled) if err := tags.FlattenAndSet(d, model.Tags); err != nil { return fmt.Errorf("setting `tags`: %+v", err)