Gallery › PostgreSQL › Azure built-in policies
Disconnections should be logged for PostgreSQL flexible servers
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.1
This policy helps audit any PostgreSQL flexible servers in your environment without log_disconnections enabled.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONFlexibleServers_EnableLogDisconnections_AINE.json · 50 lines
{
"properties": {
"displayName": "Disconnections should be logged for PostgreSQL flexible servers",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy helps audit any PostgreSQL flexible servers in your environment without log_disconnections enabled.",
"metadata": {
"version": "1.0.1",
"category": "PostgreSQL"
},
"version": "1.0.1",
"parameters": {
"effect": {
"type": "string",
"defaultValue": "AuditIfNotExists",
"allowedValues": [
"AuditIfNotExists",
"Disabled"
],
"metadata": {
"displayName": "Effect",
"description": "Enable or disable the execution of the policy"
}
}
},
"policyRule": {
"if": {
"field": "type",
"equals": "Microsoft.DBforPostgreSQL/flexibleServers"
},
"then": {
"effect": "[parameters('effect')]",
"details": {
"type": "Microsoft.DBforPostgreSQL/flexibleServers/configurations",
"name": "log_disconnections",
"existenceCondition": {
"field": "Microsoft.DBforPostgreSQL/flexibleServers/configurations/value",
"equals": "ON"
}
}
}
},
"versions": [
"1.0.1",
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/1d14b021-1bae-4f93-b36b-69695e14984a",
"name": "1d14b021-1bae-4f93-b36b-69695e14984a"
}Bylaw1d14b021-1bae-4f93-b36b-69695e14984a.bylaw.ps1 · 28 lines
# Converted from FlexibleServers_EnableLogDisconnections_AINE.json by ConvertTo-Bylaw.
Policy '1d14b021-1bae-4f93-b36b-69695e14984a' {
Properties @{
DisplayName = 'Disconnections should be logged for PostgreSQL flexible servers'
Description = 'This policy helps audit any PostgreSQL flexible servers in your environment without log_disconnections enabled.'
Version = '1.0.1'
Category = 'PostgreSQL'
PolicyVersion = '1.0.1'
Mode = 'Indexed'
}
Parameter Effect @{
Type = 'string'
AllowedValues = @('AuditIfNotExists', 'Disabled')
Default = 'AuditIfNotExists'
DisplayName = 'Effect'
Description = 'Enable or disable the execution of the policy'
}
Resource 'Microsoft.DBforPostgreSQL/flexibleServers'
AuditIfNotExists 'Microsoft.DBforPostgreSQL/flexibleServers/configurations' -Name 'log_disconnections' -Effect (Param Effect) {
Require 'value is ON' {
Field value | Must -Be 'ON'
}
}
}Source: built-in-policies/policyDefinitions/PostgreSQL/FlexibleServers_EnableLogDisconnections_AINE.json in Azure/azure-policy, under the MIT licence.
Bylaw