Gallery › SQL › Azure Community Policy
Allowed PostgreSQL SKUs
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
PostgreSQL DB creation will fail if a SKU other than what's defined in this Policy is selected.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 48 lines
{
"name": "a4749ad4-7dfe-44e4-ace6-4c1cb25395c2",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "Allowed PostgreSQL SKUs",
"description": "PostgreSQL DB creation will fail if a SKU other than what's defined in this Policy is selected.",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"mode": "All",
"parameters": {
"allowedSkus": {
"type": "Array"
},
"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.DBforPostgreSQL/servers"
},
{
"field": "Microsoft.DBforPostgreSQL/servers/sku.tier",
"notIn": "[parameters('allowedSkus')]"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawa4749ad4-7dfe-44e4-ace6-4c1cb25395c2.bylaw.ps1 · 30 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'a4749ad4-7dfe-44e4-ace6-4c1cb25395c2' {
Properties @{
DisplayName = 'Allowed PostgreSQL SKUs'
Description = 'PostgreSQL DB creation will fail if a SKU other than what''s defined in this Policy is selected.'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter AllowedSkus @{
Type = 'Array'
}
Parameter Effect @{
AllowedValues = @('Deny', 'Audit', 'Disabled')
Default = 'Audit'
DisplayName = 'Effect'
Description = 'Deny, Audit or Disabled the execution of the Policy'
}
Resource 'Microsoft.DBforPostgreSQL/servers' {
Require 'sku.tier is one of the AllowedSkus parameter' {
Field sku.tier | Must -BeIn (Param AllowedSkus)
}
}
Effect (Param Effect)
}Source: policyDefinitions/Database for PostgreSQL/allowed-postgresql-skus/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw