_This issue was originally opened by @Dushelov as hashicorp/terraform#13663. It was migrated here as part of the provider split. The original body of the issue is below._
Hi there,
0.9.2
azurerm_lb_backend_address_pool
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}"
}
None.
None.
Azure LB backend pool created and associated with avaliability set, VMs, VMs NICs.
LB backend pool created without any associations.
terraform apply
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.
None.
@tombuildsstuff Can you please look in to this issue
Unless I am reading wrong, they can't do anything with this because https://docs.microsoft.com/en-us/rest/api/load-balancer/loadbalancerbackendaddresspools doesn't seem to have a Create method.
You can associate individual NICs with the pool. The VMs must be in the same availability set.
resource "azurerm_network_interface" "nic" {
ip_configuration {
load_balancer_backend_address_pools_ids = ["${azurerm_lb_backend_address_pool.pool.id}"]
}
}
hey @Dushelov
Thanks for opening this issue - apologies for the delayed response here!
As @wimpienortje has said - it's possible to achieve this using the load_balancer_backend_address_pools_ids setting in the ip_configuration block of the azurerm_network_interface resource, like so:
variable "prefix" {
default = "tomtesttf"
}
resource "azurerm_resource_group" "test" {
name = "${var.prefix}-resource-group"
location = "West Europe"
}
resource "azurerm_virtual_network" "test" {
name = "${var.prefix}network"
address_space = ["10.0.0.0/16"]
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
resource "azurerm_subnet" "test" {
name = "internal"
resource_group_name = "${azurerm_resource_group.test.name}"
virtual_network_name = "${azurerm_virtual_network.test.name}"
address_prefix = "10.0.2.0/24"
}
resource "azurerm_public_ip" "test" {
name = "${var.prefix}-pip"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
public_ip_address_allocation = "static"
}
resource "azurerm_lb" "test" {
name = "${var.prefix}-lb"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
frontend_ip_configuration {
name = "PublicIPAddress"
public_ip_address_id = "${azurerm_public_ip.test.id}"
}
}
resource "azurerm_lb_backend_address_pool" "test" {
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
name = "BackEndAddressPool"
}
resource "azurerm_lb_nat_rule" "test" {
name = "${var.prefix}-vm1"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
protocol = "tcp"
frontend_port = "80"
backend_port = "80"
frontend_ip_configuration_name = "PublicIPAddress"
}
resource "azurerm_lb_probe" "test" {
name = "${var.prefix}-vm1"
resource_group_name = "${azurerm_resource_group.test.name}"
loadbalancer_id = "${azurerm_lb.test.id}"
protocol = "tcp"
port = "80"
interval_in_seconds = "15"
number_of_probes = "3"
}
resource "azurerm_network_interface" "test" {
name = "${var.prefix}-nic"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
ip_configuration {
name = "testconfiguration1"
subnet_id = "${azurerm_subnet.test.id}"
private_ip_address_allocation = "static"
private_ip_address = "10.0.2.4"
load_balancer_backend_address_pools_ids = ["${azurerm_lb_backend_address_pool.test.id}"]
}
}
resource "azurerm_availability_set" "test" {
name = "${var.prefix}availset"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
managed = true
}
resource "azurerm_virtual_machine" "test" {
name = "${var.prefix}-examplevm"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
network_interface_ids = ["${azurerm_network_interface.test.id}"]
vm_size = "Standard_F2"
availability_set_id = "${azurerm_availability_set.test.id}"
delete_os_disk_on_termination = true
storage_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
storage_os_disk {
name = "exampleosdisk99"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hostname"
admin_username = "testadmin"
admin_password = "Password1234!"
}
os_profile_linux_config {
disable_password_authentication = false
}
}
Thanks!
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!
Most helpful comment
hey @Dushelov
Thanks for opening this issue - apologies for the delayed response here!
As @wimpienortje has said - it's possible to achieve this using the
load_balancer_backend_address_pools_idssetting in theip_configurationblock of theazurerm_network_interfaceresource, like so:Thanks!