Gallery › General › Azure built-in policies
Not allowed resource types
Uses Condition Policy Audit Deny Disabled Mode All Version 2.0.0
Restrict which resource types can be deployed in your environment. Limiting resource types can reduce the complexity and attack surface of your environment while also helping to manage costs. Compliance results are only shown for non-compliant resources.
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 JSONInvalidResourceTypes_Deny.json · 58 lines
{
"properties": {
"displayName": "Not allowed resource types",
"policyType": "BuiltIn",
"mode": "All",
"description": "Restrict which resource types can be deployed in your environment. Limiting resource types can reduce the complexity and attack surface of your environment while also helping to manage costs. Compliance results are only shown for non-compliant resources.",
"metadata": {
"version": "2.0.0",
"category": "General"
},
"version": "2.0.0",
"parameters": {
"listOfResourceTypesNotAllowed": {
"type": "Array",
"metadata": {
"description": "The list of resource types that cannot be deployed.",
"displayName": "Not allowed resource types",
"strongType": "resourceTypes"
}
},
"effect": {
"type": "string",
"defaultValue": "Deny",
"allowedValues": [
"Audit",
"Deny",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"in": "[parameters('listOfResourceTypesNotAllowed')]"
},
{
"value": "[field('type')]",
"exists": true
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
},
"versions": [
"2.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/6c112d4e-5bc7-47ae-a041-ea2d9dccd749",
"name": "6c112d4e-5bc7-47ae-a041-ea2d9dccd749"
}Bylaw6c112d4e-5bc7-47ae-a041-ea2d9dccd749.bylaw.ps1 · 39 lines
# Converted from InvalidResourceTypes_Deny.json by ConvertTo-Bylaw.
Policy '6c112d4e-5bc7-47ae-a041-ea2d9dccd749' {
Properties @{
DisplayName = 'Not allowed resource types'
Description = 'Restrict which resource types can be deployed in your environment. Limiting resource types can reduce the complexity and attack surface of your environment while also helping to manage costs. Compliance results are only shown for non-compliant resources.'
Version = '2.0.0'
Category = 'General'
PolicyVersion = '2.0.0'
Mode = 'All'
}
Parameter ListOfResourceTypesNotAllowed @{
Type = 'Array'
DisplayName = 'Not allowed resource types'
Description = 'The list of resource types that cannot be deployed.'
Metadata = [ordered]@{ strongType = 'resourceTypes' }
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('Audit', 'Deny', 'Disabled')
Default = 'Deny'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource * {
When {
Field type | Must -BeIn (Param ListOfResourceTypesNotAllowed)
}
Require 'type is as required' {
Condition -Violation '{ "value": "[field(''type'')]", "exists": true }'
}
}
Effect (Param Effect)
}Source: built-in-policies/policyDefinitions/General/InvalidResourceTypes_Deny.json in Azure/azure-policy, under the MIT licence.
Bylaw