Figured the answer to this. The following snippet deploys a key vault, a key, a disk encryption set, and then an access policy that gives the disk encryption set access to the key vault.
{
"type": "Microsoft.KeyVault/vaults/keys",
"apiVersion": "2019-09-01",
"name": "[concat(variables('keyvaultName'), '/', variables('keyName'))]",
"location": "[variables('location')]",
"tags": "[parameters('resourceTags')]",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', variables('keyvaultName'))]"
],
"properties": {
"kty": "RSA",
"keySize": 4096
}
},
{
"type": "Microsoft.Compute/diskEncryptionSets",
"apiVersion": "2019-07-01",
"name": "[variables('diskencsetName')]",
"location": "[variables('location')]",
"tags": "[parameters('resourceTags')]",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults/keys', variables('keyvaultName'), variables('keyName'))]"
],
"identity": {
"type": "SystemAssigned"
},
"properties": {
"activeKey": {
"sourceVault": {
"id": "[resourceId('Microsoft.KeyVault/vaults', variables('keyvaultName'))]"
},
"keyUrl": "[reference(resourceId('Microsoft.KeyVault/vaults/keys', variables('keyvaultName'), variables('keyName')), '2019-09-01', 'Full').properties.keyUriWithVersion]"
}
}
},
{
"type": "Microsoft.KeyVault/vaults/accessPolicies",
"apiVersion": "2019-09-01",
"name": "[concat(variables('keyvaultName'), '/add')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/diskEncryptionSets', variables('diskencsetName'))]"
],
"properties": {
"accessPolicies": [
{
"tenantId": "[subscription().tenantId]",
"objectId": "[reference(resourceId('Microsoft.Compute/diskEncryptionSets', variables('diskencsetName')), '2019-07-01', 'Full').identity.PrincipalId]",
"permissions": {
"keys": [
"Get",
"WrapKey",
"UnwrapKey"
],
"secrets": [],
"certificates": []
}
}
]
}
},
I realized I could get the properties I need via the reference()
function so it was a matter of figuring out what I need and then putting it all into a template. Had to split out the access policies from the key vault definition so I can create the key vault and disk encryption set and then tie the two together.
Hope this helps anyone else looking for the same. Thanks.