Gallery › Network › Azure Community Policy
Enforce load balancer private ip addresses only in frontend configuration
Converted Policy Audit Deny Disabled Mode Indexed Version 1.0.0
This policy enforces private ip addresses only in frontend configuration.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 60 lines
{
"name": "c1ca69b6-98e1-457f-89a9-fec94693c4bf",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Enforce load balancer private ip addresses only in frontend configuration",
"description": "This policy enforces private ip addresses only in frontend configuration.",
"metadata": {
"category": "Network",
"createdBy": "",
"updatedBy": null,
"updatedOn": null,
"version": "1.0.0"
},
"mode": "Indexed",
"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.Network/loadBalancers",
"field": "type"
},
{
"anyOf": [
{
"exists": false,
"field": "Microsoft.Network/loadBalancers/frontendIPConfigurations[*].subnet"
},
{
"exists": true,
"field": "Microsoft.Network/loadBalancers/frontendIPConfigurations[*].publicIPAddress"
},
{
"exists": true,
"field": "Microsoft.Network/loadBalancers/frontendIPConfigurations[*].publicIPPrefix"
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawc1ca69b6-98e1-457f-89a9-fec94693c4bf.bylaw.ps1 · 47 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'c1ca69b6-98e1-457f-89a9-fec94693c4bf' {
Properties @{
DisplayName = 'Enforce load balancer private ip addresses only in frontend configuration'
Description = 'This policy enforces private ip addresses only in frontend configuration.'
Category = 'Network'
Version = '1.0.0'
Mode = 'Indexed'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Network/loadBalancers' {
Require 'frontendIPConfigurations and subnet are as required' {
Count 'frontendIPConfigurations[*]' -Where {
Field subnet | Must -Exist
} | Must -Not -Be 0
}
Require 'frontendIPConfigurations and publicIPAddress are as required' {
AnyOf {
Field frontendIPConfigurations | Must -Not -Exist
Count 'frontendIPConfigurations[*]' -Where {
Field publicIPAddress | Must -Not -Exist
} | Must -Not -Be 0
}
}
Require 'frontendIPConfigurations and publicIPPrefix are as required' {
AnyOf {
Field frontendIPConfigurations | Must -Not -Exist
Count 'frontendIPConfigurations[*]' -Where {
Field publicIPPrefix | Must -Not -Exist
} | Must -Not -Be 0
}
}
}
Effect (Param Effect)
}Source: policyDefinitions/Network/enforce-load-balancer-private-ip-addresses-only-in-frontend-configuration/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw