Open Didjacome opened 1 year ago
@Didjacome The resource is recreated for a different sku_name
. For example, changing the sku_name
from "Standard" to "Basic" will recreate the resource. Change the capacity will not trigger a recreate operation
Hello @xuzhang3 good morning actually today part of sku and capacity can be changed because of the vertical auto scaling, but the Azure Cache for Redis can not have a change from c2 to c0 according to microsoft documentation: https://learn.microsoft.com/en-us/azure/azure-cache-for-redis/cache-how-to-scale?tabs=scale-up-and-down-with-basic-standard-and-premium#prerequisiteslimitations-of-scaling-azure-cache-for-redis.
But I believe that the terraform api, when choosing a change from C2 to C0, should recreate the redis resource
@Didjacome This is a special scenario, capacity can be changed from 0 to a non-zero value but cannot from non-zero value to 0.
@xuzhang3 Exactly for this reason it is necessary to recreate the resource. in GO we can make a condition that if the value goes from any number other than 0 to 0, it will recreate the resource.
the big problem is that if you try to make a change and this cannot be done, you have to destroy the resource and recreate again
as is done in changing the name of the resource, for example
Is there an existing issue for this?
Community Note
Terraform Version
1.4.2
AzureRM Provider Version
Affected Resource(s)/Data Source(s)
azurerm_redis_cache
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
The provider should detect sku downgrade with following plan and attempt to recreate the Redis cache instead of doing an in-place update.
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
Terraform will perform the following actions:
module.redis[0].azurerm_redis_cache.main["redis-rg"] will be updated in-place
~ resource "azurerm_redis_cache" "main" { ~ capacity = 2 -> 0 id = "/subscriptions/***/resourceGroups/redis-rg/providers/Microsoft.Cache/redis/my-redis" name = "redis-bko-dev" tags = { "environment" = "dev" "managed_by" = "Terraform" }
Plan: 0 to add, 1 to change, 0 to destroy
Actual Behaviour
Terraform plan = OK Terraform apply + error
Steps to Reproduce
terraform apply -auto-approve
Invalid update request: properties.sku.Capacity cannot be updated to C0. RequestID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Important Factoids
No response
References
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.redis.fluent.models.sku.capacity?view=azure-dotnet https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/redis_cache#capacity