hashicorp / terraform-provider-azurerm

Terraform provider for Azure Resource Manager
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs
Mozilla Public License 2.0
4.52k stars 4.6k forks source link

Support for LB backend pool settings in network_interface block for azurerm_site_recovery_replicated_vm #22220

Open horvatal opened 1 year ago

horvatal commented 1 year ago

Is there an existing issue for this?

Community Note

Description

For ASR replicated items Azure supports to set a target load balancer backend pool:

In the azurerm provider it is not supported yet. Please integrate that feature so we can failover our VM smoothly to the defined LB backend pool. We are using Zone2Zone replication, so for us the backend pool ID stays the same.

The network_interface block can be extended by the recovery_lb_backend_pool_id.

New or Affected Resource(s)/Data Source(s)

azurerm_site_recovery_replicated_vm

Potential Terraform Configuration

resource "azurerm_lb_backend_address_pool" "example" {
  loadbalancer_id = azurerm_lb.example.id
  name            = "BackEndAddressPool"
}

resource "azurerm_site_recovery_replicated_vm" "vm-replication" {
  name                                      = "vm-replication"
  resource_group_name                       = azurerm_resource_group.secondary.name
  recovery_vault_name                       = azurerm_recovery_services_vault.vault.name
  source_recovery_fabric_name               = azurerm_site_recovery_fabric.primary.name
  source_vm_id                              = azurerm_virtual_machine.vm.id
  recovery_replication_policy_id            = azurerm_site_recovery_replication_policy.policy.id
  source_recovery_protection_container_name = azurerm_site_recovery_protection_container.primary.name

  target_resource_group_id                = azurerm_resource_group.secondary.id
  target_recovery_fabric_id               = azurerm_site_recovery_fabric.secondary.id
  target_recovery_protection_container_id = azurerm_site_recovery_protection_container.secondary.id

  managed_disk {
    disk_id                    = azurerm_virtual_machine.vm.storage_os_disk[0].managed_disk_id
    staging_storage_account_id = azurerm_storage_account.primary.id
    target_resource_group_id   = azurerm_resource_group.secondary.id
    target_disk_type           = "Premium_LRS"
    target_replica_disk_type   = "Premium_LRS"
  }

  network_interface {
    source_network_interface_id   = azurerm_network_interface.vm.id
    target_subnet_name            = azurerm_subnet.secondary.name
    recovery_lb_backend_pool_id   = azurerm_lb_backend_address_pool.example.id
    recovery_public_ip_address_id = azurerm_public_ip.secondary.id
  }

  depends_on = [
    azurerm_site_recovery_protection_container_mapping.container-mapping,
    azurerm_site_recovery_network_mapping.network-mapping,
    azurerm_lb_backend_address_pool,
  ]
}

References

Hinni commented 1 year ago

Any updates on this topic?

horvatal commented 6 months ago

@rcskosir Would it be possible to implement this?