Gallery › General › Azure built-in policies
[Deprecated]: Custom subscription owner roles should not exist
Uses Condition Policy Audit Disabled Mode All Version 2.0.0-deprecated Deprecated
This policy is deprecated.
ConvertTo-Bylaw converted this policy, and proved it compiles back to the same definition. Conditions the language can't express yet are written as raw JSON with Condition.
Azure Policy JSONCustomSubscription_OwnerRole_Audit.json · 86 lines
{
"properties": {
"displayName": "[Deprecated]: Custom subscription owner roles should not exist",
"policyType": "BuiltIn",
"mode": "All",
"description": "This policy is deprecated.",
"metadata": {
"version": "2.0.0-deprecated",
"category": "General",
"deprecated": true
},
"version": "2.0.0",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "Audit",
"allowedValues": [
"Audit",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.Authorization/roleDefinitions"
},
{
"field": "Microsoft.Authorization/roleDefinitions/type",
"equals": "CustomRole"
},
{
"anyOf": [
{
"not": {
"field": "Microsoft.Authorization/roleDefinitions/permissions[*].actions[*]",
"notEquals": "*"
}
},
{
"not": {
"field": "Microsoft.Authorization/roleDefinitions/permissions.actions[*]",
"notEquals": "*"
}
}
]
},
{
"anyOf": [
{
"not": {
"field": "Microsoft.Authorization/roleDefinitions/assignableScopes[*]",
"notIn": [
"[concat(subscription().id,'/')]",
"[subscription().id]",
"/"
]
}
},
{
"not": {
"field": "Microsoft.Authorization/roleDefinitions/assignableScopes[*]",
"notLike": "/providers/Microsoft.Management/*"
}
}
]
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"2.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/10ee2ea2-fb4d-45b8-a7e9-a2e770044cd9",
"name": "10ee2ea2-fb4d-45b8-a7e9-a2e770044cd9"
}Bylaw10ee2ea2-fb4d-45b8-a7e9-a2e770044cd9.bylaw.ps1 · 50 lines
# Converted from CustomSubscription_OwnerRole_Audit.json by ConvertTo-Bylaw.
Policy '10ee2ea2-fb4d-45b8-a7e9-a2e770044cd9' {
Properties @{
DisplayName = '[Deprecated]: Custom subscription owner roles should not exist'
Description = 'This policy is deprecated.'
Version = '2.0.0-deprecated'
Category = 'General'
Deprecated = $true
PolicyVersion = '2.0.0'
Mode = 'All'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.Authorization/roleDefinitions' {
When {
Field 'Microsoft.Authorization/roleDefinitions/type' | Must -Be 'CustomRole'
AnyOf {
Count 'permissions[*]' -Where {
Count 'actions[*]' -Where {
Element | Must -Be '*'
} | Must -BeGreaterThan 0
} | Must -BeGreaterThan 0
Condition '{ "not": { "field": "Microsoft.Authorization/roleDefinitions/permissions.actions[*]", "notEquals": "*" } }'
}
}
Require 'assignableScopes is as required' {
Each 'assignableScopes[*]' {
Element | Must -Not -BeIn @('[concat(subscription().id,''/'')]', '[subscription().id]', '/')
}
}
Require 'assignableScopes is as required' {
Each 'assignableScopes[*]' {
Element | Must -Not -BeLike '/providers/Microsoft.Management/*'
}
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/General/CustomSubscription_OwnerRole_Audit.json in Azure/azure-policy, under the MIT licence.
Bylaw