Terraform: azure lb backend pool not associated to avaliability set

Created on 14 Apr 2017  ยท  7Comments  ยท  Source: hashicorp/terraform

Hi there,

Terraform Version

0.9.2

Affected Resource(s)

azurerm_lb_backend_address_pool

Terraform Configuration Files

resource "azurerm_public_ip" "lbagentpip" {
  name                         = "${format("%s_%s_lbagent_pip_%s",var.domain,var.project,var.environment)}"
  location                     = "${var.location}"
  resource_group_name          = "${azurerm_resource_group.base.name}"
  domain_name_label            = "${lower(var.domain)}${lower(var.project)}lbagent${lower(var.environment)}"
  public_ip_address_allocation = "static"
}

resource "azurerm_lb" "mainagent" {
  name                = "${format("%s_%s_lbagent_%s",var.domain,var.project,var.environment)}"
  location            = "${var.location}"
  resource_group_name = "${azurerm_resource_group.base.name}"

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

resource "azurerm_lb_backend_address_pool" "privateagent" {
  name                = "${format("%s_%s_lbagent_be_%s",var.domain,var.project,var.environment)}"
  resource_group_name = "${azurerm_resource_group.base.name}"
  loadbalancer_id     = "${azurerm_lb.mainagent.id}"
}

Debug Output

None.

Panic Output

None.

Expected Behavior

Azure LB backend pool created and associated with avaliability set, VMs, VMs NICs.

Actual Behavior

LB backend pool created without any associations.

Steps to Reproduce

terraform apply

Important Factoids

As I see MS Azure LB was changed. One-two week ago this code worked correctly, cause all need to be done is choose availability set. But now need to be specified availability set, all VMs in it, and choose NIC on each VM. Checked MS documentation - they not update it yet. So to understand what need to be added you can simply try to create new LB backend pool and associate it to availability group.

References

None.

bug provideazurerm

Most helpful comment

Hi,

I had the same problem kind of - new to terraform. Add you back end load balancer azurerm_lb_backend_address_pool.id to the NIC load_balancer_backend_address_pools_ids

Tim

resource "azurerm_network_interface" "webserver01-nic" {
  name                = "webserver01-nic"
  location            = "${var.location}"
  resource_group_name = "${azurerm_resource_group.webservers-rg.name}"

  ip_configuration {
    name                          = "webServer01internal-ip"
    subnet_id                     = "${azurerm_subnet.webserver-subnet.id}"
    private_ip_address_allocation = "dynamic"
    load_balancer_backend_address_pools_ids = ["${azurerm_lb_backend_address_pool.webserver-lb-backend.id}"]
  }
}

resource "azurerm_lb" "webserver-lb" {
  name                = "webserver-lb"
  location            = "${var.location}"
  resource_group_name = "${azurerm_resource_group.webservers-rg.name}"

  frontend_ip_configuration {
    name                 = "webserverpublic-ip"
    public_ip_address_id = "${azurerm_public_ip.webserverpublic-ip.id}"
  }
}

resource "azurerm_lb_backend_address_pool" "webserver-lb-backend" {
  name                = "webserver-lb-backend"
  resource_group_name = "${azurerm_resource_group.webservers-rg.name}"
  loadbalancer_id     = "${azurerm_lb.webserver-lb.id}"
}

All 7 comments

+1 here
Forced recreate (to remove "location" depreciation warnings) of LB backend pool however no associated availability set, VM, VM NICs.

+1

It seems that it works the other way around now.
You have to create a NIC and attach it to the load balancer backend pool
Terraform NIC docs

Hi,

I had the same problem kind of - new to terraform. Add you back end load balancer azurerm_lb_backend_address_pool.id to the NIC load_balancer_backend_address_pools_ids

Tim

resource "azurerm_network_interface" "webserver01-nic" {
  name                = "webserver01-nic"
  location            = "${var.location}"
  resource_group_name = "${azurerm_resource_group.webservers-rg.name}"

  ip_configuration {
    name                          = "webServer01internal-ip"
    subnet_id                     = "${azurerm_subnet.webserver-subnet.id}"
    private_ip_address_allocation = "dynamic"
    load_balancer_backend_address_pools_ids = ["${azurerm_lb_backend_address_pool.webserver-lb-backend.id}"]
  }
}

resource "azurerm_lb" "webserver-lb" {
  name                = "webserver-lb"
  location            = "${var.location}"
  resource_group_name = "${azurerm_resource_group.webservers-rg.name}"

  frontend_ip_configuration {
    name                 = "webserverpublic-ip"
    public_ip_address_id = "${azurerm_public_ip.webserverpublic-ip.id}"
  }
}

resource "azurerm_lb_backend_address_pool" "webserver-lb-backend" {
  name                = "webserver-lb-backend"
  resource_group_name = "${azurerm_resource_group.webservers-rg.name}"
  loadbalancer_id     = "${azurerm_lb.webserver-lb.id}"
}

and what does one do if the nodes were not created with Terraform!

Hi, personally I'd just create TF code to build everything. You could take a look at importing the existing resources https://www.terraform.io/docs/import/index.html ?

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.

Was this page helpful?
0 / 5 - 0 ratings