For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/security/code_security/iac_security/iac_rules/terraform-azure-log-retention-is-not-set.md.
A documentation index is available at /llms.txt.
The log_retention server parameter in Azure PostgreSQL determines whether database logs are retained, which is essential for auditing and troubleshooting purposes. If this parameter is set to OFF, as shown below, log data will not be persisted, potentially hindering investigations into security incidents or operational issues:
resource "azurerm_postgresql_configuration" "example" {
name = "log_retention"
resource_group_name = data.azurerm_resource_group.example.name
server_name = azurerm_postgresql_server.example.name
value = "OFF"
}
To address this, ensure that log_retention is set to ON, as in the configuration below, so that important logs are retained and available for review:
resource "azurerm_postgresql_configuration" "example" {
name = "log_retention"
resource_group_name = data.azurerm_resource_group.example.name
server_name = azurerm_postgresql_server.example.name
value = "ON"
}
Failing to enable log retention can result in loss of critical data needed for compliance, monitoring, and incident response.