Control: Enable log_retention_days on PostgreSQL Servers
Description
Ensure server parameter 'log_retention_days' is greater than 3 days for PostgreSQL Database Server.
Usage
Run the control in your terminal:
powerpipe control run terraform_azure_compliance.control.postgres_db_server_log_retention_days_3Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_azure_compliance.control.postgres_db_server_log_retention_days_3 --shareSQL
This control uses a named query:
with postgresql_server as (  select    *  from    terraform_resource  where    type = 'azurerm_postgresql_server'), log_disconnections_configuration as (  select    *  from    terraform_resource  where    type = 'azurerm_postgresql_configuration'    and (attributes_std ->> 'name') = 'log_retention_days'    and (attributes_std ->> 'value')::int > 3)select  a.address as resource,  case    when (s.attributes_std ->> 'server_name') is not null then 'ok'    else 'alarm'  end as status,  split_part(a.address, '.', 2) || case    when (s.attributes_std ->> 'server_name') is not null then ' log files are retained for more than 3 days'    else ' og files are retained for 3 days or lesser'  end || '.' reason    , a.path || ':' || a.start_linefrom  postgresql_server as a  left join log_disconnections_configuration as s on a.name = ( split_part((s.attributes_std ->> 'server_name'), '.', 2));