Open mne-unitn opened 2 years ago
Hi @mne-unitn, thanks for this issue. Do you experience this on a functional level as well?
To be honest, I think this might be a technical issue with the plan
construction rather than that it's impacting the request_routing_rule
itself (which already existed on Azure) and its behaviour. When the resource is updated, all rules are expanded for the Azure API at once, and send to the Azure API combined with all other settings. Azure takes care of the updates on the resource, and I expect that only the second rule is added and the first remains functional during that period.
To fix the plan
, we'd have to make sure that the items are stored in state with an index value calculated by the hash of the attributes of the set which are retrieved upon a plan
. I'm unsure whether and how we can make this work, but wanted to give you already a heads-up that it might not influence the behaviour with Azure.
@tombuildsstuff Do you think we'd be able to fix this, or are we limited by the Terraform core? I'm not familiar enough with the TypeSet
to know on first sight if this is possible or not for a complicated schema like this:
"request_routing_rule": {
Type: pluginsdk.TypeSet,
Required: true,
MinItems: 1,
Elem: &pluginsdk.Resource{
Schema: map[string]*pluginsdk.Schema{
"name": {
Type: pluginsdk.TypeString,
Required: true,
},
"rule_type": {
Type: pluginsdk.TypeString,
Required: true,
ValidateFunc: validation.StringInSlice([]string{
string(network.ApplicationGatewayRequestRoutingRuleTypeBasic),
string(network.ApplicationGatewayRequestRoutingRuleTypePathBasedRouting),
}, false),
},
"http_listener_name": {
Type: pluginsdk.TypeString,
Required: true,
},
"backend_address_pool_name": {
Type: pluginsdk.TypeString,
Optional: true,
},
"backend_http_settings_name": {
Type: pluginsdk.TypeString,
Optional: true,
},
"url_path_map_name": {
Type: pluginsdk.TypeString,
Optional: true,
},
"redirect_configuration_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
"rewrite_rule_set_name": {
Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: validation.StringIsNotEmpty,
},
"backend_address_pool_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"backend_http_settings_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"http_listener_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"url_path_map_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"redirect_configuration_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
"rewrite_rule_set_id": {
Type: pluginsdk.TypeString,
Computed: true,
},
},
},
},
Hi @mne-unitn, thanks for this issue. Do you experience this on a functional level as well?
I think you are right. Looking at the logs on the Azure side, it seems the api recognizes the correct diff and applies only the different configuration parts.
thank you
Hello @mne-unitn, @aristosvo please any update on this?
I know there are related issues and some statements there promised this being fixed with coming 3.x release which apparently didn't happen. The problem still persists with even newest AzureRM provider and terraform core.
It behaves as described here https://github.com/hashicorp/terraform-provider-azurerm/issues/16136
Type result backend_address_pool ✔ works, only one change detected backend_http_settings ❌ does NOT work, all settings deleted and readded http_listener ❌ does NOT work, all settings deleted and readded probe ✔ works, only one change detected redirect_configuration ❌ does NOT work, all settings deleted and readded request_routing_rule ❌ does NOT work, all settings deleted and readded url_path_map ❌ does NOT work, all settings deleted and readded
Also related - https://github.com/hashicorp/terraform-provider-azurerm/issues/6896#issuecomment-1083586519
Thank you for any answer...
Community Note
Terraform (and AzureRM Provider) Version
Terraform v1.0.8 provider registry.terraform.io/hashicorp/azurerm v2.82.0
Affected Resource(s)
azurerm_application_gateway
Terraform Configuration Files
Debug Output
Panic Output
Expected Behaviour
When I enable the second request_routing_rule (the one commented out), I would expect terraform to just add that specific rule.
Actual Behaviour
When I enable the second request_routing_rule (the one commented out), terraform destroys all the request_routing_rules and recreates them.
Steps to Reproduce
terraform apply
terraform apply
Important Factoids
References
0000