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 can't create LoadBalancer rule with probe #9311

Closed
pmcq opened this issue Oct 10, 2016 · 3 comments · Fixed by #9401
Closed

azurerm can't create LoadBalancer rule with probe #9311

pmcq opened this issue Oct 10, 2016 · 3 comments · Fixed by #9401

Comments

@pmcq
Copy link

pmcq commented Oct 10, 2016

I am unable to create resources that refer to LoadBalancer probe_ids or backend_address_pool_ids. I can create load balancers, rules, and NICs that don't refer to a particular probe/backend_address_pool or manually set the string name, but I can't use something like "${azurerm_lb_probe.web_probe.id}"

Terraform Version

Terraform v0.7.6-dev (d83770d+CHANGES)

Affected Resource(s)

Please list the resources as a list, for example:

  • azurerm_lb_backend_address_pool
  • azurerm_lb_probe

Resources using these:

  • azurerm_lb_rule
  • azurerm_network_interface

Terraform Configuration Files

resource "azurerm_lb" "web_lb" {
  name = "${var.environment}-WEB"
  location = "West US"
  resource_group_name = "${azurerm_resource_group.main.name}"

  frontend_ip_configuration {
    name = "${var.environment}-WEB-ipconfig"
    subnet_id = "${azurerm_subnet.edge.id}"
  }
}

resource "azurerm_lb_backend_address_pool" "web_backendpool" {
  name = "${var.environment}-WEB-backendpool"
  location = "West US"
  resource_group_name = "${azurerm_resource_group.main.name}"
  loadbalancer_id = "${azurerm_lb.web_lb.id}"
}

resource "azurerm_lb_probe" "web_probe" {
  name = "${var.environment}-WEB-probe"
  location = "West US"                                                   
  resource_group_name = "${azurerm_resource_group.main.name}"            
  loadbalancer_id = "${azurerm_lb.web_lb.id}"                            
  protocol = "Http"
  port = 9000                                                            
  request_path = "/ping"                                                 
  interval_in_seconds = 5
} 

resource "azurerm_lb_rule" "web_lbrule" {
  name = "${var.environment}-WEB-lbrule"
  location = "West US"
  resource_group_name = "${azurerm_resource_group.main.name}"            
  loadbalancer_id = "${azurerm_lb.web_lb.id}"                            
  frontend_ip_configuration_name = "${var.environment}-WEB-ipconfig"     
  protocol = "Tcp"
  frontend_port = 80
  backend_port = 9000
  probe_id = "${azurerm_lb_probe.web_probe.id}"
  backend_address_pool_id = "${azurerm_lb_backend_address_pool.web_backendpool.id}"
}

Debug Output

Please provider a link to a GitHub Gist containing the complete debug output: https://www.terraform.io/docs/internals/debugging.html. Please do NOT paste the debug output in the issue; just paste a link to the Gist.

Expected Behavior

Load balancer rule with the given probe & backend address pool should have been created

Actual Behavior

Azure returned an error stating that the ID for the probe/backend address pool refers to the wrong type:

{"code":"InvalidJsonReferenceWrongType","message":"Reference Id /subscriptions/ffafcfaf-21f1-4594-bb65-9076e00b15f7/resourceGroups/mainResourceGroup/providers/Microsoft.Network/loadBalancers/azure-WEB is referencing resource of a wrong type. The Id is expected to reference resources of type loadBalancers/backendAddressPools. Path properties.ipConfigurations[0].properties.loadBalancerBackendAddressPools[0]."}

And doing a terraform plan shows that the IDs being used seem to refer to the LoadBalancer itself instead of the ID of the Probe.

+ azurerm_lb_rule.web_lbrule
    backend_address_pool_id:        "/subscriptions/ffafcfaf-21f1-4594-bb65-9076e00b15f7/resourceGroups/mainResourceGroup/providers/Microsoft.Network/loadBalancers/azure-WEB"
    backend_port:                   "9000"
    enable_floating_ip:             "false"
    frontend_ip_configuration_id:   "<computed>"
    frontend_ip_configuration_name: "azure-WEB-ipconfig"
    frontend_port:                  "80"
    idle_timeout_in_minutes:        "<computed>"
    load_distribution:              "<computed>"
    loadbalancer_id:                "/subscriptions/ffafcfaf-21f1-4594-bb65-9076e00b15f7/resourceGroups/mainResourceGroup/providers/Microsoft.Network/loadBalancers/azure-WEB"
    location:                       "westus"
    name:                           "azure-WEB-lbrule"
    probe_id:                       "/subscriptions/ffafcfaf-21f1-4594-bb65-9076e00b15f7/resourceGroups/mainResourceGroup/providers/Microsoft.Network/loadBalancers/azure-WEB"
    protocol:                       "Tcp"
    resource_group_name:            "mainResourceGroup"

I'm new to terraform, but it seems like this an issue in this section of code (for probes):

read, err := lbClient.Get(resGroup, loadBalancerName, "")
if err != nil {
return errwrap.Wrapf("Error Getting LoadBalancer {{err}}", err)
}
if read.ID == nil {
return fmt.Errorf("Cannot read LoadBalancer %s (resource group %s) ID", loadBalancerName, resGroup)
}
d.SetId(*read.ID)

Steps to Reproduce

  1. terraform apply

Important Factoids

This stuff is super new (and great!)

References

Azure resource manager load balancer support was just added in this pull request:

@pmcq
Copy link
Author

pmcq commented Oct 10, 2016

Update: after creating a probe I've been able to manually get the probe ID and succesfully terraform apply i.e. use
probe_id = "/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.Network/loadBalancers/azure-WEB/probes/azure-WEB-probe"
so I do think the probe ID field is set improperly

@ThatRendle
Copy link

ThatRendle commented Oct 16, 2016

All the output IDs for LB probes, rules and backend pools are just the ID of the LB itself; you can construct the correct ID using e.g. "${azurerm_lb.test.id}/backendAddressPools/BackendPool1" where BackendPool1 is the name you gave the pool.

It would be better if the output IDs were set to this, since it can be derived from the information supplied when creating the pool/rule/probe.

cf. https://github.com/Azure/azure-quickstart-templates/blob/master/201-2-vms-loadbalancer-lbrules/azuredeploy.json which is where I got this pattern from.

cc @stack72

rainmaker pushed a commit to pivotal-cf/terraforming-azure that referenced this issue Oct 17, 2016
- Backend address pools and probes don't output their own id. When
  hashicorp/terraform#9311 is fixed, we can
  stop doing this

[#132341947]
Signed-off-by: Raina Masand <rmasand@pivotal.io>
jen20 added a commit that referenced this issue Oct 18, 2016
@ghost
Copy link

ghost commented Apr 21, 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 21, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants