Open omgjlk opened 1 year ago
Hi @omgjlk , I try to reproduce the issue but seems I can't with below config. Could it be the affinity_cookie_name
property has been changed out of Terraform scope? And could you please export the debug log with TF_LOG=DEBUG TF_LOG_PATH=/home/test/tf.log terraform apply
?
Thanks.
I'll work on a real reproduction instead of an edited version of what we're doing in production. At the same time I'll get DEBUG log output.
For our production workload I've just set the affinity_cookie_name to what TF was saying it was and that resulted in TF saying that there were no changes necessary.
Its always replacing for me no matter what. I am using AKS and that enables AGIC which replacess all the backends, whenver I deploy terraform again after that it completely replaces it all again, breaking my ingress.
Same for me. It always updates.
Is there an existing issue for this?
Community Note
I've got an application gateway with an http backend. That backend has
cookie_based_affinity
set toDisabled
. There is no definition for aaffinity_cookie_name
. However every run of Terraform wants to replace the resource, and in the details I can see:The replacement resource does not show an attribute for
affinity_cookie_name
being added.I assume that there is something on Azure side that is automatically creating an affinity cookie name when the resource is created, and now Terraform is comparing state to resource and notices a difference.
If I add the attribute to my terraform file the resource is no longer refreshed.
Terraform Version
1.4.4
AzureRM Provider Version
3.50.0
Affected Resource(s)/Data Source(s)
azurerm_application_gateway
Terraform Configuration Files
resource "azurerm_application_gateway" "tfe_prod" { name = tfe_prod resource_group_name = module.site.rg_network_name location = module.site.rg_network_location
zones = ["1", "2", "3"]
sku { name = "Standard_v2" tier = "Standard_v2" }
gateway_ip_configuration { name = "${local.tfe_prod_full_name}-gw-subnet" subnet_id = module.site.app_gateway_subnet_id }
autoscale_configuration { min_capacity = 2 max_capacity = 125 }
frontend_ip_configuration { name = local.tfe_prod_frontend_ip_configuration_name public_ip_address_id = azurerm_public_ip.tfe_prod.id }
backend_address_pool { name = local.tfe_prod_backend_address_pool_name }
TFE Application
backend_http_settings { name = local.tfe_prod_backend_https_settings_name cookie_based_affinity = "Disabled" port = 443 protocol = "Https" request_timeout = 60 host_name = local.tfe_prod_service_fqdn connection_draining { enabled = true drain_timeout_sec = 300 } } }
Debug Output/Panic Output
Terraform will perform the following actions:
azurerm_application_gateway.tfe_prod will be updated in-place
~ resource "azurerm_application_gateway" "tfe_prod" { id = "/subscriptions//resourceGroups/network/providers/Microsoft.Network/applicationGateways/azure-eastus-terraform-enterprise-production" name = "azure-eastus-terraform-enterprise-production" tags = { "catalog_service" = "terraform-enterprise" "environment" = "production" }
Expected Behaviour
The resource does not change every plan.
Actual Behaviour
The resource is changing every plan.
Steps to Reproduce
Create an application gateway with a backend_http_settings that disable cookie_based_affinity and do not define an affinity_cookie_name. Plan/apply. Plan again and notice Terraform wanting to replace the backend_http_settings.
Important Factoids
No response
References
Looks similar to https://github.com/hashicorp/terraform-provider-azurerm/issues/16695