Gallery › HDInsight › Azure built-in policies
Configure Azure HDInsight clusters with private endpoints
Converted Policy DeployIfNotExists Disabled Mode Indexed Version 1.0.0
Private endpoints connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to Azure HDInsight clusters, you can reduce data leakage risks. Learn more about private links at: https://aka.ms/hdi.pl.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONPrivateEndpoint_DINE.json · 199 lines
{
"properties": {
"displayName": "Configure Azure HDInsight clusters with private endpoints",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "Private endpoints connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to Azure HDInsight clusters, you can reduce data leakage risks. Learn more about private links at: https://aka.ms/hdi.pl.",
"metadata": {
"version": "1.0.0",
"category": "HDInsight"
},
"version": "1.0.0",
"parameters": {
"privateEndpointSubnetId": {
"type": "String",
"metadata": {
"displayName": "Private endpoint subnet ID",
"description": "A subnet with private endpoint network policies disabled.",
"strongType": "Microsoft.Network/virtualNetworks/subnets"
}
},
"groupId": {
"type": "String",
"metadata": {
"displayName": "Group ID",
"description": "Target group id (sub resource type) for the private endpoint."
}
},
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
},
"allowedValues": [
"DeployIfNotExists",
"Disabled"
],
"defaultValue": "DeployIfNotExists"
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.HDInsight/clusters"
},
{
"anyOf": [
{
"field": "Microsoft.HDInsight/clusters/networkProperties.privateLink",
"equals": "Enabled"
},
{
"count": {
"field": "Microsoft.HDInsight/clusters/privateLinkConfigurations[*]"
},
"greaterOrEquals": 1
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.HDInsight/clusters/privateEndpointConnections",
"existenceCondition": {
"field": "Microsoft.HDInsight/clusters/privateEndpointConnections/privateLinkServiceConnectionState.status",
"equals": "Approved"
},
"roleDefinitionIds": [
"/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c"
],
"deployment": {
"properties": {
"mode": "incremental",
"parameters": {
"name": {
"value": "[field('name')]"
},
"serviceId": {
"value": "[field('id')]"
},
"groupId": {
"value": "[parameters('groupId')]"
},
"privateEndpointSubnetId": {
"value": "[parameters('privateEndpointSubnetId')]"
}
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"serviceId": {
"type": "string"
},
"groupId": {
"type": "string"
},
"privateEndpointSubnetId": {
"type": "string"
}
},
"variables": {
"privateEndpointName": "[concat('pe-',substring(parameters('name'),0,min(length(parameters('name')),50)),'-',uniquestring(deployment().name))]"
},
"resources": [
{
"type": "Microsoft.Resources/deployments",
"name": "[variables('privateEndpointName')]",
"apiVersion": "2020-06-01",
"properties": {
"mode": "Incremental",
"expressionEvaluationOptions": {
"scope": "inner"
},
"template": {
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"serviceId": {
"type": "string"
},
"privateEndpointSubnetId": {
"type": "string"
},
"groupId": {
"type": "string"
},
"subnetLocation": {
"type": "string"
}
},
"variables": {
"privateEndpointName": "[deployment().name]"
},
"resources": [
{
"name": "[variables('privateEndpointName')]",
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-07-01",
"location": "[parameters('subnetLocation')]",
"tags": {},
"properties": {
"subnet": {
"id": "[parameters('privateEndpointSubnetId')]"
},
"privateLinkServiceConnections": [
{
"name": "[variables('privateEndpointName')]",
"properties": {
"privateLinkServiceId": "[parameters('serviceId')]",
"groupIds": [
"[parameters('groupId')]"
],
"requestMessage": "Request to auto approve."
}
}
],
"manualPrivateLinkServiceConnections": []
}
}
]
},
"parameters": {
"serviceId": {
"value": "[parameters('serviceId')]"
},
"groupId": {
"value": "[parameters('groupId')]"
},
"privateEndpointSubnetId": {
"value": "[parameters('privateEndpointSubnetId')]"
},
"subnetLocation": {
"value": "[reference(first(take(split(parameters('privateEndpointSubnetId'),'/subnets'),1)),'2020-07-01','Full').location]"
}
}
}
}
]
}
}
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/2676090a-4baf-46ac-9085-4ac02cc50e3e",
"name": "2676090a-4baf-46ac-9085-4ac02cc50e3e"
}Bylaw2676090a-4baf-46ac-9085-4ac02cc50e3e.bylaw.ps1 · 53 lines
# Converted from PrivateEndpoint_DINE.json by ConvertTo-Bylaw.
Policy '2676090a-4baf-46ac-9085-4ac02cc50e3e' {
Properties @{
DisplayName = 'Configure Azure HDInsight clusters with private endpoints'
Description = 'Private endpoints connect your virtual networks to Azure services without a public IP address at the source or destination. By mapping private endpoints to Azure HDInsight clusters, you can reduce data leakage risks. Learn more about private links at: https://aka.ms/hdi.pl.'
Version = '1.0.0'
Category = 'HDInsight'
PolicyVersion = '1.0.0'
Mode = 'Indexed'
}
Parameter PrivateEndpointSubnetId @{
Type = 'String'
DisplayName = 'Private endpoint subnet ID'
Description = 'A subnet with private endpoint network policies disabled.'
Metadata = [ordered]@{ strongType = 'Microsoft.Network/virtualNetworks/subnets' }
}
Parameter GroupId @{
Type = 'String'
DisplayName = 'Group ID'
Description = 'Target group id (sub resource type) for the private endpoint.'
}
Parameter Effect @{
AllowedValues = @('DeployIfNotExists', 'Disabled')
Default = 'DeployIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.HDInsight/clusters' {
Require 'networkProperties.privateLink is not Enabled' {
Field networkProperties.privateLink | Must -Not -Be 'Enabled' -IfPresent
}
Require 'privateLinkConfigurations is as required' {
Count 'privateLinkConfigurations[*]' | Must -Be 0
}
}
DeployIfNotExists 'Microsoft.HDInsight/clusters/privateEndpointConnections' -Role 'Contributor' -Effect (Param Effect) {
Require 'privateLinkServiceConnectionState.status is Approved' {
Field privateLinkServiceConnectionState.status | Must -Be 'Approved'
}
Deployment -TemplateFile './templates/2676090a-4baf-46ac-9085-4ac02cc50e3e.json' -Parameters ([ordered]@{
name = (Arm '[field(''name'')]')
serviceId = (Arm '[field(''id'')]')
groupId = (Param GroupId)
privateEndpointSubnetId = (Param PrivateEndpointSubnetId)
})
}
}Its deployment templates are written beside it:
templates/2676090a-4baf-46ac-9085-4ac02cc50e3e.json
Source: built-in-policies/policyDefinitions/HDInsight/PrivateEndpoint_DINE.json in Azure/azure-policy, under the MIT licence.
Bylaw