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

azurerm_network_interface doesn't handle load_balancer_inbound_nat_rules_ids properly #10561

Closed
bbc88ks opened this issue Dec 6, 2016 · 2 comments · Fixed by #10834
Closed

Comments

@bbc88ks
Copy link

bbc88ks commented Dec 6, 2016

Terraform Version

Terraform v0.7.13

Affected Resource(s)

  • azurerm_network_interface
  • azurerm_lb_nat_rule

Terraform Configuration Files

resource "azurerm_lb" "lb" {
    name = "BackupService"
    location = "${var.region}"
    resource_group_name = "${azurerm_resource_group.resource_group.name}"

    frontend_ip_configuration {
      name = "PublicIPAddress"
      public_ip_address_id = "${azurerm_public_ip.lb.id}"
    }
}

resource "azurerm_lb_backend_address_pool" "backend_pool" {
  location = "${var.region}"
  resource_group_name = "${azurerm_resource_group.resource_group.name}"
  loadbalancer_id = "${azurerm_lb.lb.id}"
  name = "BackendAddressPool"
  depends_on = ["azurerm_lb.lb"]
}

resource "azurerm_lb_probe" "lb_probe" {
  location = "${var.region}"
  resource_group_name = "${azurerm_resource_group.resource_group.name}"
  loadbalancer_id = "${azurerm_lb.lb.id}"
  name = "backup_service_probe"
  port = 443
}

resource "azurerm_lb_rule" "https" {
  location = "${var.region}"
  resource_group_name = "${azurerm_resource_group.resource_group.name}"
  loadbalancer_id = "${azurerm_lb.lb.id}"
  name = "https_in"
  protocol = "Tcp"
  frontend_port = 443
  backend_port = 443
  frontend_ip_configuration_name = "PublicIPAddress"
  probe_id = "${azurerm_lb_probe.lb_probe.id}"
  backend_address_pool_id = "${azurerm_lb_backend_address_pool.backend_pool.id}"
  depends_on = ["azurerm_lb.lb", "azurerm_lb_backend_address_pool.backend_pool", "azurerm_lb_probe.lb_probe"]
}

resource "azurerm_lb_nat_rule" "rdp" {
  count = "${var.backup_service_vms}"
  location = "${var.region}"
  resource_group_name = "${azurerm_resource_group.resource_group.name}"
  loadbalancer_id = "${azurerm_lb.lb.id}"
  name = "rdp_access${count.index + 1}"
  protocol = "Tcp"
  frontend_port = "${3389 + count.index}"
  backend_port = 3389
  frontend_ip_configuration_name = "PublicIPAddress"
}

resource "azurerm_lb_nat_rule" "winrm" {
  count = "${var.backup_service_vms}"
  location = "${var.region}"
  resource_group_name = "${azurerm_resource_group.resource_group.name}"
  loadbalancer_id = "${azurerm_lb.lb.id}"
  name = "winrm_access${count.index + 1}"
  protocol = "Tcp"
  frontend_port = "${5986 + count.index}"
  backend_port = 5986
  frontend_ip_configuration_name = "PublicIPAddress"
}

resource "azurerm_network_interface" "network_interface" {
    count = "${var.backup_service_vms}"
    name = "BackupServiceNIC${count.index + 1}"
    location = "${var.region}"
    resource_group_name = "${azurerm_resource_group.resource_group.name}"
    depends_on = ["azurerm_lb_backend_address_pool.backend_pool", "azurerm_lb_rule.https", "azurerm_lb_nat_rule.winrm", "azurerm_lb_nat_rule.rdp"]

    ip_configuration {
        name = "IPConfig${count.index + 1}"
        subnet_id = "${azurerm_subnet.subnet.id}"
        private_ip_address_allocation = "dynamic"
        load_balancer_backend_address_pools_ids = ["${azurerm_lb_backend_address_pool.backend_pool.id}"]
        load_balancer_inbound_nat_rules_ids = ["${element(azurerm_lb_nat_rule.winrm.*.id, count.index)}", "${element(azurerm_lb_nat_rule.rdp.*.id, count.index)}" ]
    }
}

Debug Output

Terraform Version: 0.7.13
Resource ID: azurerm_network_interface.network_interface.0
Mismatch reason: attribute mismatch: ip_configuration.3947973451.load_balancer_backend_address_pools_ids.18293703
2016/12/06 15:45:07 [DEBUG] plugin: /usr/local/bin/terraform: plugin process exited
2016/12/06 15:45:07 [DEBUG] plugin: /usr/local/bin/terraform: plugin process exited
2016/12/06 15:45:07 [DEBUG] plugin: /usr/local/bin/terraform: plugin process exited
2016/12/06 15:45:07 [DEBUG] plugin: /usr/local/bin/terraform: plugin process exited
2016/12/06 15:45:07 [DEBUG] plugin: /usr/local/bin/terraform: plugin process exited
2016/12/06 15:45:07 [DEBUG] plugin: /usr/local/bin/terraform: plugin process exited
Diff One (usually from plan): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"ip_configuration.3947973451.load_balancer_inbound_nat_rules_ids.2080932363":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/inboundNatRules/rdp_access1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "location":*terraform.ResourceAttrDiff{Old:"", New:"eastus", NewComputed:false, NewRemoved:false, NewExtra:"eastus", RequiresNew:true, Sensitive:false, Type:0x0}, "internal_fqdn":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_backend_address_pools_ids.18293703":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/backendAddressPools/BackendAddressPool", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "network_security_group_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.name":*terraform.ResourceAttrDiff{Old:"", New:"IPConfig1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_inbound_nat_rules_ids.#":*terraform.ResourceAttrDiff{Old:"0", New:"2", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.private_ip_address_allocation":*terraform.ResourceAttrDiff{Old:"", New:"dynamic", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"BackupServiceNIC1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "enable_ip_forwarding":*terraform.ResourceAttrDiff{Old:"", New:"false", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "dns_servers.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "internal_dns_name_label":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/HeadlessNetwork/subnets/BackupServiceSubnet", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_inbound_nat_rules_ids.585640722":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/inboundNatRules/winrm_access1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.private_ip_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "resource_group_name":*terraform.ResourceAttrDiff{Old:"", New:"test", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_backend_address_pools_ids.#":*terraform.ResourceAttrDiff{Old:"0", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/HeadlessNetwork/subnets/BackupServiceSubnet", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "mac_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.public_ip_address_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "tags.%":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "virtual_machine_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "private_ip_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.load_balancer_backend_address_pools_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.private_ip_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.load_balancer_backend_address_pools_ids.18293703":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/backendAddressPools/BackendAddressPool", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "applied_dns_servers.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.public_ip_address_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.load_balancer_inbound_nat_rules_ids.585640722":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/inboundNatRules/winrm_access1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_inbound_nat_rules_ids.2080932363":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/inboundNatRules/rdp_access1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.name":*terraform.ResourceAttrDiff{Old:"", New:"IPConfig1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.private_ip_address_allocation":*terraform.ResourceAttrDiff{Old:"", New:"dynamic", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.3947973451.load_balancer_inbound_nat_rules_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"2", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyTainted:false}
Diff Two (usually from apply): *terraform.InstanceDiff{mu:sync.Mutex{state:0, sema:0x0}, Attributes:map[string]*terraform.ResourceAttrDiff{"tags.%":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.public_ip_address_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_inbound_nat_rules_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"2", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.name":*terraform.ResourceAttrDiff{Old:"", New:"IPConfig1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_inbound_nat_rules_ids.2080932363":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/inboundNatRules/rdp_access1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "name":*terraform.ResourceAttrDiff{Old:"", New:"BackupServiceNIC1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "mac_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.subnet_id":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/virtualNetworks/HeadlessNetwork/subnets/BackupServiceSubnet", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "enable_ip_forwarding":*terraform.ResourceAttrDiff{Old:"", New:"false", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "network_security_group_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "virtual_machine_id":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_inbound_nat_rules_ids.585640722":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/inboundNatRules/winrm_access1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "applied_dns_servers.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_backend_address_pools_ids.18293703":*terraform.ResourceAttrDiff{Old:"", New:"/subscriptions/49f1d5a7-ba66-4d22-bb84-021a0a894577/resourceGroups/test/providers/Microsoft.Network/loadBalancers/BackupService/backendAddressPools/BackendAddressPool", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "resource_group_name":*terraform.ResourceAttrDiff{Old:"", New:"test", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:true, Sensitive:false, Type:0x0}, "private_ip_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "location":*terraform.ResourceAttrDiff{Old:"", New:"eastus", NewComputed:false, NewRemoved:false, NewExtra:"eastus", RequiresNew:true, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.load_balancer_backend_address_pools_ids.#":*terraform.ResourceAttrDiff{Old:"", New:"1", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.private_ip_address":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "dns_servers.#":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "internal_dns_name_label":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "ip_configuration.1355756746.private_ip_address_allocation":*terraform.ResourceAttrDiff{Old:"", New:"dynamic", NewComputed:false, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}, "internal_fqdn":*terraform.ResourceAttrDiff{Old:"", New:"", NewComputed:true, NewRemoved:false, NewExtra:interface {}(nil), RequiresNew:false, Sensitive:false, Type:0x0}}, Destroy:false, DestroyTainted:false}

Expected Behavior

The NIC should be created with multiple nat rules assigned.

Actual Behavior

  • azurerm_network_interface.network_interface.1: network.InterfacesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"DuplicateResourceName","message":"Resource /subscriptions//resourceGroups//providers/Microsoft.Network/networkInterfaces/ has two child resources with the same name (IPConfig2)."}]
  • azurerm_network_interface.network_interface.0: network.InterfacesClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="InvalidRequestFormat" Message="Cannot parse the request." Details=[{"code":"DuplicateResourceName","message":"Resource /subscriptions//resourceGroups//providers/Microsoft.Network/networkInterfaces/ has two child resources with the same name (IPConfig1)."}]
@bbc88ks
Copy link
Author

bbc88ks commented Dec 6, 2016

It works if I change

load_balancer_inbound_nat_rules_ids = ["${element(azurerm_lb_nat_rule.winrm.*.id, count.index)}", "${element(azurerm_lb_nat_rule.rdp.*.id, count.index)}" ]

to:

load_balancer_inbound_nat_rules_ids = ["${element(azurerm_lb_nat_rule.winrm.*.id, count.index)}"]

@ghost
Copy link

ghost commented Apr 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants