Gallery › SQL › Azure Community Policy
PostgreSQL flexible servers administrator - Enforce only specific administrator principal types
Converted Policy Audit Deny Disabled Mode All Version 1.0.0
PostgreSQL flexible servers supports different principal types to be Administrator, allowed values; Group, ServicePrincipal, Unknown, User
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 55 lines
{
"name": "d78f353a-a5e7-4747-8d31-62f361bafac7",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"mode": "All",
"displayName": "PostgreSQL flexible servers administrator - Enforce only specific administrator principal types",
"description": "PostgreSQL flexible servers supports different principal types to be Administrator, allowed values; Group, ServicePrincipal, Unknown, User",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"parameters": {
"effect": {
"type": "String",
"defaultValue": "Deny",
"allowedValues": [
"Audit",
"Disabled",
"Deny"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
},
"allowedTypes": {
"type": "Array",
"defaultValue": [
"Group"
],
"metadata": {
"displayName": "Allowed Administrator Prinicpal Types.",
"description": "Valid values are; Group, ServicePrincipal, Unknown, User - https://learn.microsoft.com/en-us/azure/templates/microsoft.dbforpostgresql/flexibleservers/administrators?pivots=deployment-language-bicep#administratorpropertiesforaddoradministratorproperties"
}
}
},
"policyRule": {
"if": {
"allOf": [
{
"field": "type",
"equals": "Microsoft.DBforPostgreSQL/flexibleServers/administrators"
},
{
"value": "[contains(parameters('allowedTypes'),field('Microsoft.DBforPostgreSQL/flexibleServers/administrators/principalType'))]",
"notEquals": "true"
}
]
},
"then": {
"effect": "[parameters('effect')]"
}
}
}
}Bylawd78f353a-a5e7-4747-8d31-62f361bafac7.bylaw.ps1 · 33 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy 'd78f353a-a5e7-4747-8d31-62f361bafac7' {
Properties @{
DisplayName = 'PostgreSQL flexible servers administrator - Enforce only specific administrator principal types'
Description = 'PostgreSQL flexible servers supports different principal types to be Administrator, allowed values; Group, ServicePrincipal, Unknown, User'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('Audit', 'Disabled', 'Deny')
Default = 'Deny'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Parameter AllowedTypes @{
Type = 'Array'
Default = @('Group')
DisplayName = 'Allowed Administrator Prinicpal Types.'
Description = 'Valid values are; Group, ServicePrincipal, Unknown, User - https://learn.microsoft.com/en-us/azure/templates/microsoft.dbforpostgresql/flexibleservers/administrators?pivots=deployment-language-bicep#administratorpropertiesforaddoradministratorproperties'
}
Resource 'Microsoft.DBforPostgreSQL/flexibleServers/administrators' {
Require 'principalType is as required' {
Arm '[contains(parameters(''allowedTypes''),field(''Microsoft.DBforPostgreSQL/flexibleServers/administrators/principalType''))]' | Must -Be 'true'
}
}
Effect (Param Effect)
}Source: policyDefinitions/SQL/enforce-postgresql-administrator-principal-types/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw