Review customer-managed keys for Managed Disk

Associate a compatible Disk Encryption Set when organizational policy requires customer-managed keys.

Description

Azure encrypts managed disks with platform-managed keys by default. If your organization must control the key, associate the disk with an approved Disk Encryption Set.

Potential impact

Disabling the key or revoking the encryption set’s access can make the disk and its VM unavailable.

Remediation

For an ordinary managed disk, specify disk_encryption_set_id. For a Confidential VM disk protected by a customer-managed key, use a compatible security_type with secure_vm_disk_encryption_set_id. The two ID properties are mutually exclusive. Check Key Vault permissions and key rotation and recovery, then verify the encryption set attached to the disk.

Examples

The examples attach the ordinary disk encryption set to the same 128 GiB Premium disk. Configure the referenced set and its key access first.

Before

hcl
resource "azurerm_managed_disk" "example" {
  name                 = "example-disk"
  location             = azurerm_resource_group.example.location
  resource_group_name  = azurerm_resource_group.example.name
  storage_account_type = "Premium_LRS"
  create_option        = "Empty"
  disk_size_gb         = 128
}

After

hcl
resource "azurerm_managed_disk" "example" {
  name                   = "example-disk"
  location               = azurerm_resource_group.example.location
  resource_group_name    = azurerm_resource_group.example.name
  storage_account_type   = "Premium_LRS"
  create_option          = "Empty"
  disk_size_gb           = 128
  disk_encryption_set_id = azurerm_disk_encryption_set.example.id
}

References