Gallery › PostgreSQL › Azure built-in policies
Log connections should be enabled for PostgreSQL flexible servers
Converted Policy AuditIfNotExists Disabled Mode Indexed Version 1.0.0
This policy helps audit any PostgreSQL flexible servers in your environment without log_connections setting enabled.
ConvertTo-Bylaw converted this policy, and proved that the file compiles back to the same definition.
Azure Policy JSONFlexibleServers_EnableLogConnections_AINE.json · 49 lines
{
"properties": {
"displayName": "Log connections should be enabled for PostgreSQL flexible servers",
"policyType": "BuiltIn",
"mode": "Indexed",
"description": "This policy helps audit any PostgreSQL flexible servers in your environment without log_connections setting enabled.",
"metadata": {
"version": "1.0.0",
"category": "PostgreSQL"
},
"version": "1.0.0",
"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_connections",
"existenceCondition": {
"field": "Microsoft.DBforPostgreSQL/flexibleServers/configurations/value",
"equals": "ON"
}
}
}
},
"versions": [
"1.0.0"
]
},
"id": "/providers/Microsoft.Authorization/policyDefinitions/086709ac-11b5-478d-a893-9567a16d2ae3",
"name": "086709ac-11b5-478d-a893-9567a16d2ae3"
}Bylaw086709ac-11b5-478d-a893-9567a16d2ae3.bylaw.ps1 · 28 lines
# Converted from FlexibleServers_EnableLogConnections_AINE.json by ConvertTo-Bylaw.
Policy '086709ac-11b5-478d-a893-9567a16d2ae3' {
Properties @{
DisplayName = 'Log connections should be enabled for PostgreSQL flexible servers'
Description = 'This policy helps audit any PostgreSQL flexible servers in your environment without log_connections setting enabled.'
Version = '1.0.0'
Category = 'PostgreSQL'
PolicyVersion = '1.0.0'
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_connections' -Effect (Param Effect) {
Require 'value is ON' {
Field value | Must -Be 'ON'
}
}
}Source: built-in-policies/policyDefinitions/PostgreSQL/FlexibleServers_EnableLogConnections_AINE.json in Azure/azure-policy, under the MIT licence.
Bylaw