Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.18.0 - Error removing/updating load balancer rules #7691

Closed
hbuckle opened this issue Jul 10, 2020 · 11 comments · Fixed by #8006 or #10263
Closed

2.18.0 - Error removing/updating load balancer rules #7691

hbuckle opened this issue Jul 10, 2020 · 11 comments · Fixed by #8006 or #10263
Assignees
Labels
bug service/load-balancers upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR
Milestone

Comments

@hbuckle
Copy link
Contributor

hbuckle commented Jul 10, 2020

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.12.9

  • provider.azurerm v2.18.0

Affected Resource(s)

  • azurerm_lb_rule

Expected Behavior

Something seems to have gone terribly wrong with deleting load balancer rules in 2.18.0 (I guess due to the new network SDK?), I'm seeing the error below.
It is fine with 2.17.0

Actual Behavior

Error: Error Creating/Updating Load Balancer "management" (Resource Group "cbuk-core-cibuild173945-sfha-uksouth"): network.LoadBalancersClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|sharedz1|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/30bcd4a9-4db4-4650-9681-420cad939976."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|systemz3|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/f238075c-2ede-4fb0-87a3-cb7d02bead59."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|sharedz3|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/8127b097-ac32-4f5d-b42a-7332ef3b4e82."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z1|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/7c2705e3-691f-41af-8440-8a6859e07351."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z2|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/80961ff3-64be-4fe9-b255-efa45bdafc0c."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|sharedz2|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/f2589883-33d7-4e06-a84c-e0e07fd18638."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|systemz1|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/6b6f9d8d-33c9-4694-91ba-74c4ab3fddf1."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z3|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/d3458da3-bd1e-488f-99e3-0e0374651e7a."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|systemz2|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/7a81fa47-26bf-4f2b-b8da-9de216f99a63."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z1|virtualMachines|1|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/d1260d1b-e317-44d7-a836-62c09b811e6a."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z1|virtualMachines|2|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/f17c9c33-dfd5-4089-886a-db818796f7f4."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z1|virtualMachines|3|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/71a23a75-f11a-4069-a161-77dfbb0d5a5e."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z1|virtualMachines|4|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/448a3115-3af8-429b-9126-def0034484f6."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z3|virtualMachines|1|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/f60c2431-8ec2-4151-a7fe-7fbeba0eca17."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z3|virtualMachines|2|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/436843e6-f740-4db2-a75b-b81c42ec323f."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z3|virtualMachines|3|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/23c90f13-f9d1-49d6-bd73-5c1092903a04."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z3|virtualMachines|4|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/3a8d05e6-37da-46ce-a76b-1782ee057dbe."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z2|virtualMachines|1|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/2c3183ef-617e-4899-9eb4-f45c9b3cd9f3."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z2|virtualMachines|2|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/bd155699-fd49-48f9-843b-67cd22cd6383."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z2|virtualMachines|3|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/36d72ce3-1d5a-4b2f-ae29-ba401880f15b."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|ci1z2|virtualMachines|4|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/outbound/loadBalancerBackendAddresses/b94dbb0f-2999-4613-ac59-a7030ae85d60."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|systemz3|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/management/loadBalancerBackendAddresses/dda2105f-a1b6-4f58-8dce-d4b8fd477582."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|systemz1|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/management/loadBalancerBackendAddresses/9426514c-33b3-47f8-bd2b-dfd71c8d8bf3."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/cbuk-core-cibuild173945-sfha-uksouth/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|systemz2|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/management/loadBalancerBackendAddresses/638719a2-c00a-495b-8244-2b794e25098d."}]

Steps to Reproduce

  1. terraform destroy
@abrignola
Copy link

same here, please fix

@magodo
Copy link
Collaborator

magodo commented Jul 11, 2020

@hbuckle Thank you for submitting this issue.
I locally tested against the example, creating the rule with v2.17.0 and destroy the rule with v2.18.0. Whilst it works as expected.
Additionally, the acctest for the azurerm_lb_rule itself works with no issue.

From the error message, it seems there is some special config needed to trigger this error. So would you please provide the detailed (simplified) tf config so as I can reproduce the issue and investigate further?

@magodo magodo self-assigned this Jul 11, 2020
@hbuckle
Copy link
Contributor Author

hbuckle commented Jul 11, 2020

You need to actually have some VMs attached to the loadbalancer to trigger it. Here's a simplified example from my module

terraform {
  required_version = "~> 0.12"
}

provider "azurerm" {
  version = "~> 2.0"
  features {}
}

resource "azurerm_resource_group" "hbtest" {
  name     = "hbtest"
  location = var.location
}

locals {
  lb_final = ["hbtest1"]
  lb_rule_all = [
    {
      node_type               = "hbtest1"
      name                    = "rule1"
      lb_name                 = "hbtest1"
      protocol                = "Tcp"
      frontend_port           = 5000
      backend_port            = 5000
      load_distribution       = "Default"
      idle_timeout_in_minutes = 10
    }
  ]
  node_type_final = [
    {
      key  = "hbtest1"
      name = "hbtest1"
    }
  ]
}

resource "azurerm_lb" "hbtest" {
  for_each            = toset(local.lb_final)
  name                = each.key
  resource_group_name = azurerm_resource_group.hbtest.name
  location            = azurerm_resource_group.hbtest.location
  sku                 = "Standard"

  frontend_ip_configuration {
    name      = each.key
    subnet_id = var.subnet_id
  }
}

resource "azurerm_lb_backend_address_pool" "hbtest" {
  for_each            = toset(local.lb_final)
  name                = each.key
  resource_group_name = azurerm_resource_group.hbtest.name
  loadbalancer_id     = azurerm_lb.hbtest[each.key].id
}

resource "azurerm_lb_probe" "hbtest" {
  for_each = {
    for lb_rule in local.lb_rule_all : "${lb_rule.lb_name}.${lb_rule.name}" => lb_rule
  }
  name                = each.value.name
  resource_group_name = azurerm_resource_group.hbtest.name
  loadbalancer_id     = azurerm_lb.hbtest[each.value.lb_name].id
  port                = each.value.backend_port
}

resource "azurerm_lb_rule" "hbtest" {
  for_each = {
    for lb_rule in local.lb_rule_all : "${lb_rule.lb_name}.${lb_rule.name}" => lb_rule
  }
  name                           = each.value.name
  resource_group_name            = azurerm_resource_group.hbtest.name
  loadbalancer_id                = azurerm_lb.hbtest[each.value.lb_name].id
  protocol                       = each.value.protocol
  frontend_port                  = each.value.frontend_port
  backend_port                   = each.value.backend_port
  load_distribution              = each.value.load_distribution
  idle_timeout_in_minutes        = each.value.idle_timeout_in_minutes
  frontend_ip_configuration_name = azurerm_lb.hbtest[each.value.lb_name].frontend_ip_configuration[0].name
  probe_id                       = azurerm_lb_probe.hbtest[each.key].id
  backend_address_pool_id        = azurerm_lb_backend_address_pool.hbtest[each.value.lb_name].id
  disable_outbound_snat          = true
}

resource "azurerm_virtual_machine_scale_set" "hbtest" {
  for_each = {
    for node_type in local.node_type_final : node_type.name => node_type
  }
  name                   = each.value.name
  resource_group_name    = azurerm_resource_group.hbtest.name
  location               = azurerm_resource_group.hbtest.location
  upgrade_policy_mode    = "Automatic"
  overprovision          = false
  single_placement_group = true

  sku {
    name     = "Standard_B2ms"
    tier     = "Standard"
    capacity = 3
  }

  storage_profile_image_reference {
    publisher = "MicrosoftWindowsServer"
    offer     = "WindowsServer"
    sku       = "2019-datacenter-core-smalldisk-g2"
    version   = "latest"
  }

  storage_profile_os_disk {
    create_option     = "FromImage"
    caching           = "ReadWrite"
    managed_disk_type = "Premium_LRS"
  }

  os_profile {
    computer_name_prefix = each.value.name
    admin_username       = "azureuser"
    admin_password       = "Qwerty12345!"
  }

  os_profile_windows_config {
    provision_vm_agent        = true
    enable_automatic_upgrades = false
  }

  network_profile {
    name    = "primary"
    primary = true

    ip_configuration {
      name      = "primary"
      primary   = true
      subnet_id = var.subnet_id
      load_balancer_backend_address_pool_ids = [
        azurerm_lb_backend_address_pool.hbtest[each.value.key].id
      ]
    }
  }
}

If you then change one of the port values in lb_rule_all and run terraform apply you see the error

terraform apply
azurerm_resource_group.hbtest: Refreshing state... [id=/subscriptions/xxx/resourceGroups/hbtest]
azurerm_lb.hbtest["hbtest1"]: Refreshing state... [id=/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1]
azurerm_lb_backend_address_pool.hbtest["hbtest1"]: Refreshing state... [id=/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/backendAddressPools/hbtest1]
azurerm_lb_probe.hbtest["hbtest1.rule1"]: Refreshing state... [id=/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/probes/rule1]
azurerm_virtual_machine_scale_set.hbtest["hbtest1"]: Refreshing state... [id=/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Compute/virtualMachineScaleSets/hbtest1]
azurerm_lb_rule.hbtest["hbtest1.rule1"]: Refreshing state... [id=/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/loadBalancingRules/rule1]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # azurerm_lb_probe.hbtest["hbtest1.rule1"] will be updated in-place
  ~ resource "azurerm_lb_probe" "hbtest" {
        id                  = "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/probes/rule1"
        interval_in_seconds = 15
        load_balancer_rules = [
            "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/loadBalancingRules/rule1",
        ]
        loadbalancer_id     = "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1"
        name                = "rule1"
        number_of_probes    = 2
      ~ port                = 5000 -> 5001
        protocol            = "Tcp"
        resource_group_name = "hbtest"
    }

  # azurerm_lb_rule.hbtest["hbtest1.rule1"] will be updated in-place
  ~ resource "azurerm_lb_rule" "hbtest" {
        backend_address_pool_id        = "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/backendAddressPools/hbtest1"
      ~ backend_port                   = 5000 -> 5001
        disable_outbound_snat          = true
        enable_floating_ip             = false
        enable_tcp_reset               = false
        frontend_ip_configuration_id   = "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/frontendIPConfigurations/hbtest1"
        frontend_ip_configuration_name = "hbtest1"
      ~ frontend_port                  = 5000 -> 5001
        id                             = "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/loadBalancingRules/rule1"
        idle_timeout_in_minutes        = 10
        load_distribution              = "Default"
        loadbalancer_id                = "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1"
        name                           = "rule1"
        probe_id                       = "/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/probes/rule1"
        protocol                       = "Tcp"
        resource_group_name            = "hbtest"
    }

Plan: 0 to add, 2 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

azurerm_lb_probe.hbtest["hbtest1.rule1"]: Modifying... [id=/subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/loadBalancers/hbtest1/probes/rule1]

Error: Error Creating/Updating Load Balancer "hbtest1" (Resource Group "hbtest"): network.LoadBalancersClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|hbtest1|virtualMachines|0|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/hbtest1/loadBalancerBackendAddresses/8e9d53ce-6394-41ba-b7f1-bff27c113548."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|hbtest1|virtualMachines|2|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/hbtest1/loadBalancerBackendAddresses/0bc5d909-c119-437e-9af4-397f0879405e."},{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference /subscriptions/xxx/resourceGroups/hbtest/providers/Microsoft.Network/networkInterfaces/|providers|Microsoft.Compute|virtualMachineScaleSets|hbtest1|virtualMachines|1|networkInterfaces|primary/ipConfigurations/primary on backend pool addresses /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools//loadBalancerBackendAddresses/ and /subscriptions//resourceGroups//providers/Microsoft.Network/loadBalancers//backendAddressPools/hbtest1/loadBalancerBackendAddresses/0e4c0214-11fa-4b34-8edf-f8091d834ee7."}]

@ghost ghost removed the waiting-response label Jul 11, 2020
@hbuckle hbuckle changed the title 2.18.0 - Error removing load balancer rules 2.18.0 - Error removing/updating load balancer rules Jul 11, 2020
geekzter added a commit to geekzter/azure-vdc that referenced this issue Jul 12, 2020
* Fix casing of TF_VAR_resource_suffix

* Erase workspace by default

* Pin provider 2.17
  (2.18 is breaks the pipeline: hashicorp/terraform-provider-azurerm#7691)

* ip & ip prefix rules for SQL DB

* Disable NetworkMonitoring solution

* Unpin Terraform provider in vdc-terraform-apply-ci & vdc-terraform-apply-cd CI pipelines

* Declare versions for all providers

* erase.ps1 support multiple suffixes
@magodo
Copy link
Collaborator

magodo commented Jul 13, 2020

@hbuckle I can reproduce it with your config now, thank you!
I have submitted an azure issue Azure/azure-rest-api-specs#10104 for this. In the meanwhile, I will try to reach out to the service side to figure out the next step for this.

@magodo magodo added upstream/microsoft Indicates that there's an upstream issue blocking this issue/PR bug labels Jul 13, 2020
@magodo
Copy link
Collaborator

magodo commented Jul 14, 2020

The reason for this issue is that service can't tolerate the client sending properties.backendAddressPools.n.properties.backendIPConfigurations in request body for load balancer resource since 2020-05-01, as it is a READ-ONLY attribute.
(this only occurs when azurerm_lb's sku is Standard)
Currently, Azure Go SDK can trim the READ-ONLY attributes during marshalling, but only for the root level attributes, so, in this case, Go SDK will still marshal the attribute into request body. This is tracked in issue: Azure/autorest.go#438.

@mrkMadhur
Copy link

Hi Guys,
When can we expect a resolution for this issue?
Also, I noticed that the rules were getting deployed in sometimes.

@magodo
Copy link
Collaborator

magodo commented Jul 18, 2020

@mrkMadhur The issue Azure/azure-rest-api-specs#10104 should be addressed in Swagger by Azure/azure-rest-api-specs#10131 (though the state is still open). When the change is reflected in next Go SDK release, we will hopefully update the Go SDK in provider to involve the fix.

@salsop
Copy link

salsop commented Aug 2, 2020

I've just hit this same issue with duplicate, rolled back to AzureRM 2.17 and all working.

Error: Error Creating/Updating LoadBalancer: network.LoadBalancersClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"DuplicateIpConfigurationReferenceOnBackendAddressPool","message":"Found duplicate ipConfiguration reference ....

@ghost
Copy link

ghost commented Aug 20, 2020

This has been released in version 2.24.0 of the provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. As an example:

provider "azurerm" {
    version = "~> 2.24.0"
}
# ... other configuration ...

@ZackMattor
Copy link

I know this is closed - but thanks for fixing this ! Just hit this this morning, upgraded, and it resolved the issue!

🔥

@ghost
Copy link

ghost commented Sep 18, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 [email protected]. Thanks!

@ghost ghost locked and limited conversation to collaborators Sep 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.