Gallery › SQL › Azure Community Policy
PostgreSQL flexible servers should log checkpoints
Converted Policy AuditIfNotExists Disabled Mode All Version 1.0.0
This policy helps audit any PostgreSQL databases in your environment without log_checkpoints setting enabled.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONazurepolicy.json · 44 lines
{
"name": "7a2deb93-6f4f-4668-8697-be314e342085",
"type": "Microsoft.Authorization/policyDefinitions",
"properties": {
"displayName": "PostgreSQL flexible servers should log checkpoints",
"description": "This policy helps audit any PostgreSQL databases in your environment without log_checkpoints setting enabled.",
"metadata": {
"version": "1.0.0",
"category": "SQL"
},
"mode": "All",
"parameters": {
"effect": {
"type": "String",
"metadata": {
"displayName": "Effect",
"description": "AuditIfNotExists or Disabled the execution of the Policy"
},
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"defaultValue": "AuditIfNotExists"
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.DBforPostgreSQL/flexibleServers"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.DBforPostgreSQL/flexibleServers/configurations",
"name": "log_checkpoints",
"existenceCondition": {
"field": "Microsoft.DBforPostgreSQL/flexibleServers/configurations/value",
"equals": "ON"
}
}
}
}
}
}Bylaw7a2deb93-6f4f-4668-8697-be314e342085.bylaw.ps1 · 26 lines
# Converted from azurepolicy.json by ConvertTo-Bylaw.
Policy '7a2deb93-6f4f-4668-8697-be314e342085' {
Properties @{
DisplayName = 'PostgreSQL flexible servers should log checkpoints'
Description = 'This policy helps audit any PostgreSQL databases in your environment without log_checkpoints setting enabled.'
Version = '1.0.0'
Category = 'SQL'
Mode = 'All'
}
Parameter Effect @{
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'AuditIfNotExists or Disabled the execution of the Policy'
}
Resource 'Microsoft.DBforPostgreSQL/flexibleServers'
AuditIfNotExists 'Microsoft.DBforPostgreSQL/flexibleServers/configurations' -Name 'log_checkpoints' -Effect (Param Effect) {
Require 'value is ON' {
Field value | Must -Be 'ON'
}
}
}Source: policyDefinitions/Database for PostgreSQL/postgresql-flexible-servers-should-log-checkpoints/azurepolicy.json in Azure/Community-Policy, under the MIT licence.
Bylaw