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

Add Support for recoveryAzureVMSize on azurerm_site_recovery_replicated_vm #23729

Open viewegchris opened 10 months ago

viewegchris commented 10 months ago

Is there an existing issue for this?

Community Note

Description

Currently it's not possible to configure or update the target VM SKU on azurerm_site_recovery_replicated_vm. If the SKU on Source VM is changed, it gets updated in the Source settings but not on the Target settings. Only recreating the whole replication will update the Target settings.

But it is possible to update the Target settings via Azure Portal or Azure ARM API -> recoveryAzureVMSize.

Configuring the recovery VM Size should also be possible via azurerm_site_recovery_replicated_vm

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

azurerm_site_recovery_replicated_vm

Potential Terraform Configuration

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

  //New Attribute 
  recovery_vm_size = "Standard_D2s_v5"

  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_public_ip_address_id = azurerm_public_ip.secondary.id
  }
}

References

https://learn.microsoft.com/en-us/rest/api/site-recovery/replication-protected-items/create?tabs=HTTP#a2areplicationdetails recoveryAzureVMSize

horvatal commented 6 months ago

any news here?