Skip to content

Commit

Permalink
azurerm_lb_backend_address_pool: mark backend_address as computed (#…
Browse files Browse the repository at this point in the history
…10481)

Fix the regression caused by #10291, that the associated NIC will be cleared by LB BAP
  • Loading branch information
magodo authored Feb 5, 2021
1 parent c55a5a5 commit 0310e84
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ func resourceArmLoadBalancerBackendAddressPool() *schema.Resource {
"backend_address": {
Type: schema.TypeSet,
Optional: true,
// Making this block optional for standard sku LB associating NIC, where the `name` will be computed after
// NIC associates with LB BAP by azurerm_network_interface_backend_address_pool_association.
Computed: true,
MinItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,11 +275,79 @@ func (r LoadBalancerBackendAddressPool) standardSkuNIC(data acceptance.TestData)
return fmt.Sprintf(`
%s
resource "azurerm_virtual_network" "test" {
name = "testvnet-%[2]d"
location = azurerm_resource_group.test.location
resource_group_name = azurerm_resource_group.test.name
address_space = ["192.168.0.0/16"]
}
resource "azurerm_subnet" "test" {
name = "testsubnet-%[2]d"
resource_group_name = azurerm_resource_group.test.name
virtual_network_name = azurerm_virtual_network.test.name
address_prefixes = ["192.168.0.0/24"]
}
resource "azurerm_network_interface" "test" {
name = "testnic-%[2]d"
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 = "Dynamic"
}
}
resource "azurerm_linux_virtual_machine_scale_set" "test" {
name = "acctestvmss-%[2]d"
resource_group_name = azurerm_resource_group.test.name
location = azurerm_resource_group.test.location
sku = "Standard_F2"
instances = 1
admin_username = "adminuser"
admin_password = "P@ssword1234!"
disable_password_authentication = false
source_image_reference {
publisher = "Canonical"
offer = "UbuntuServer"
sku = "16.04-LTS"
version = "latest"
}
os_disk {
storage_account_type = "Standard_LRS"
caching = "ReadWrite"
}
network_interface {
name = "example"
primary = true
ip_configuration {
name = "internal"
primary = true
subnet_id = azurerm_subnet.test.id
load_balancer_backend_address_pool_ids = [azurerm_lb_backend_address_pool.test.id]
}
}
}
resource "azurerm_network_interface_backend_address_pool_association" "test" {
ip_configuration_name = "testconfiguration1"
network_interface_id = azurerm_network_interface.test.id
backend_address_pool_id = azurerm_lb_backend_address_pool.test.id
}
resource "azurerm_lb_backend_address_pool" "test" {
loadbalancer_id = azurerm_lb.test.id
name = "Address-pool-%d"
name = "Address-pool-%[2]d"
}
`, template, data.RandomInteger)
`, template, data.RandomIntOfLength(8))
}

func (r LoadBalancerBackendAddressPool) standardSkuIPBasic(data acceptance.TestData) string {
Expand Down

0 comments on commit 0310e84

Please sign in to comment.