Open darren-johnson opened 2 years ago
Hi @darren-johnson , thanks for opening the issue.
Did you mean that there will be a new Key Vault for the replica disk and the Key Vault does not exist before the VM onboarded, and there should be a property target_key_vault_id
where provider should copy the encryption key from the original Key Vault to it?
In my opinion, for a replica disk, the encryption settings should be the same one in the same Key Vault instead of copying the encryption key to a new Key Vault. Therefore, the disk_encryption_key
property could use the same one with the original disk, which will be known at this point.
For example the config could be as below:
data "azurerm_managed_disk" "example" {
name = azurerm_windows_virtual_machine.example.os_disk[0].name
resource_group_name = azurerm_windows_virtual_machine.example.resource_group_name
}
resource "azurerm_site_recovery_replicated_vm" "example" {
...
managed_disk {
...
target_disk_encryption {
disk_encryption_key {
secret_url = data.azurerm_managed_disk.example.encryption_settings[0].disk_encryption_key[0].secret_url
vault_id = data.azurerm_managed_disk.example.encryption_settings[0].disk_encryption_key[0].source_vault_id
}
}
}
}
If it helps or I misunderstand the issue or any further questions, please leave comments.
Is there an existing issue for this?
Community Note
Terraform Version
1.2.8
AzureRM Provider Version
3.22.0
Affected Resource(s)/Data Source(s)
azurerm_site_recovery_replicated_vm
Terraform Configuration Files
Debug Output/Panic Output
Expected Behaviour
When onboarding a VM to Azure Site Recovery that uses disk encryption via the portal you are prompted for a target key vault.
At this point the target key vault key and secret do not exist, therefore it is impossible to supply these in the code before the VM is onboarded.
This could be amended so that instead the Target Key Vault ID is requested.
Therefore the block below could simply be replaced by the argument
target_key_vault_id
This had been previously requested in Issue 7239 but wasn't implemented.
Hopefully this is enough to get this resource fixed.
Actual Behaviour
No response
Steps to Reproduce
No response
Important Factoids
No response
References
No response