Control: Network Watcher flow logs should have retention set to 90 days or greater
Description
This control is non-compliant if Network Watcher flow log retention is set to less than 90 days.
Usage
Run the control in your terminal:
powerpipe control run terraform_azure_compliance.control.network_watcher_flow_log_retention_period_90_days
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_azure_compliance.control.network_watcher_flow_log_retention_period_90_days --share
SQL
This control uses a named query:
select address as resource, case when (attributes_std -> 'retention_policy' ->> 'enabled') = 'false' then 'alarm' when (attributes_std -> 'retention_policy' ->> 'enabled') = 'true' and (attributes_std -> 'retention_policy' ->> 'days')::int >= 90 then 'ok' else 'alarm' end as status, split_part(address, '.', 2) || case when (attributes_std -> 'retention_policy' ->> 'enabled') = 'false' then ' retention policy disabled' else ' retention set to ' || (attributes_std -> 'retention_policy' ->> 'days') || ' day(s)' end || '.' reason , path || ':' || start_linefrom terraform_resourcewhere type = 'azurerm_network_watcher_flow_log';