I’m struggling to find and obtain the secretURL used for the disk encryption key encryption block for the azurerm_managed_disk resource block in terraform. Anyone know how to obtain this? The docs states this, but not sure how to get the secret of the key in the key vault.
secret_url – (Required) The URL to the Key Vault Secret used as the
Disk Encryption Key. This can be found as id on the
azurerm_key_vault_secret resource.
data "azurerm_key_vault" "kv" {
name = var.disk_encryption_key_vault_name
resource_group_name = var.disk_encryption_key_rg
}
data "azurerm_key_vault_key" "encryption-kv" {
name = var.disk_encryption_key_name
key_vault_id = data.azurerm_key_vault.kv.id
}
resource "azurerm_managed_disk" "data" {
count = var.data_disk_count
name = "${var.vm_name}-DataDisk-${count.index + 1}"
location = var.location
resource_group_name = var.resource_group_name
storage_account_type = var.data_disk_storage_account_type
create_option = "Empty"
disk_size_gb = var.data_disk_size_gb
tags = var.tags
encryption_settings {
enabled = true
disk_encryption_key {
secret_url =
source_vault_id = data.azurerm_key_vault_key.encryption-kv.key_vault_id
}
key_encryption_key {
key_url = "https://${data.azurerm_key_vault.kv.name}.vault.usgovcloudapi.net/keys/${var.disk_encryption_key_name}/${data.azurerm_key_vault_key.encryption-kv.version}"
source_vault_id = data.azurerm_key_vault_key.encryption-kv.key_vault_id
}
}
}