Gallery › Authorization › Azure Community Policy
Custom roles are not allowed
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
This policy will audit or deny the creation of RBAC custom roles.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 45 lines
{
"name": "30451e59-638a-4313-a426-49b27b1bf97a",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Custom roles are not allowed",
"description": "This policy will audit or deny the creation of RBAC custom roles.",
"metadata": {
"version": "1.0.0",
"category": "Authorization"
},
"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": [
{
"field": "type",
"equals": "Microsoft.Authorization/roleDefinitions"
},
{
"field": "Microsoft.Authorization/roleDefinitions/type",
"notEquals": "BuiltInRole"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylaw30451e59-638a-4313-a426-49b27b1bf97a.bylaw.ps1 · 27 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '30451e59-638a-4313-a426-49b27b1bf97a' {
Properties @{
DisplayName = 'Custom roles are not allowed'
Description = 'This policy will audit or deny the creation of RBAC custom roles.'
Version = '1.0.0'
Category = 'Authorization'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.Authorization/roleDefinitions' {
Require 'type is BuiltInRole' {
Field 'Microsoft.Authorization/roleDefinitions/type' | Must -Be 'BuiltInRole'
}
}
Effect (Param Effect)
}Source: policyDefinitions/Authorization/custom-roles-are-not-allowed/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw