Gallery › Network › Azure Community Policy
Prevent cross tenant Private Link for key vault
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy prevents private link between tenants for key vault.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 56 lines
{
"name": "9e8c1efe-dc00-418c-baa2-2b155005cf6a",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Prevent cross tenant Private Link for key vault",
"description": "This policy prevents private link between tenants for key vault.",
"metadata": {
"category": "Network",
"createdBy": "",
"updatedBy": null,
"updatedOn": null,
"version": "1.0.0"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Deny, Audit or Disabled the execution of the Policy"
},
"allowedValues": [
"Deny",
"Audit",
"Disabled"
],
"defaultValue": "Audit"
}
},
"policyRule": {
"if": {
"allOf": [
{
"equals": "Microsoft.KeyVault/vaults/privateEndpointConnections",
"field": "type"
},
{
"anyOf": [
{
"exists": false,
"field": "Microsoft.KeyVault/vaults/privateEndpointConnections/privateEndpoint.id"
},
{
"notEquals": "[subscription().subscriptionId]",
"value": "[split(concat(field('Microsoft.KeyVault/vaults/privateEndpointConnections/privateEndpoint.id'), '//'), '/')[2]]"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw9e8c1efe-dc00-418c-baa2-2b155005cf6a.bylaw.ps1 · 31 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '9e8c1efe-dc00-418c-baa2-2b155005cf6a' {
Properties @{
DisplayName = 'Prevent cross tenant Private Link for key vault'
Description = 'This policy prevents private link between tenants for key vault.'
Category = 'Network'
Version = '1.0.0'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.KeyVault/vaults/privateEndpointConnections' {
Require 'privateEndpoint.id exists' {
Field privateEndpoint.id | Must -Exist
}
Require 'privateEndpoint.id is as required' {
Arm '[split(concat(field(''Microsoft.KeyVault/vaults/privateEndpointConnections/privateEndpoint.id''), ''//''), ''/'')[2]]' | Must -Be (Arm '[subscription().subscriptionId]')
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/prevent-cross-tenant-private-link-for-key-vault/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw