Review HSM protection for Key Vault keys

Choose a key type that meets organizational protection requirements.

Description

If policy requires key operations in a hardware security module (HSM), use a Premium Key Vault and select RSA-HSM or EC-HSM for the required algorithm.

Potential impact

A software-protected key in a Premium vault can still fall short of an HSM requirement.

Remediation

Terraform replaces the key when key_type changes. Keep the existing resource and create a separately named HSM key in a second Terraform resource. Switch new operations to it and test them. Retain the old key as long as existing data needs it for decryption.

Examples

Both excerpts use the same key name, 3072-bit length and permitted operations. Only the second selects RSA-HSM.

Before

hcl
resource "azurerm_key_vault_key" "example" {
  name         = "application-key"
  key_vault_id = azurerm_key_vault.example.id
  key_type     = "RSA"
  key_size     = 3072
  key_opts     = ["encrypt", "decrypt", "wrapKey", "unwrapKey"]
}

After

hcl
resource "azurerm_key_vault_key" "example" {
  name         = "application-key"
  key_vault_id = azurerm_key_vault.example.id
  key_type     = "RSA-HSM"
  key_size     = 3072
  key_opts     = ["encrypt", "decrypt", "wrapKey", "unwrapKey"]
}

References