turbot/steampipe-mod-terraform-azure-compliance

Control: Monitor log profiles should have retention set to 365 days or greater

Description

This control is non-compliant if Monitor log profile retention is set to less than 365 days.

Usage

Run the control in your terminal:

powerpipe control run terraform_azure_compliance.control.monitor_log_profile_retention_365_days

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run terraform_azure_compliance.control.monitor_log_profile_retention_365_days --share

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std -> 'retention_policy' ->> 'enabled')::boolean and (attributes_std -> 'retention_policy' ->> 'days')::int < 365 then 'alarm'
when (attributes_std -> 'retention_policy' ->> 'enabled')::boolean and (attributes_std -> 'retention_policy' ->> 'days')::int >= 365 then 'ok'
else 'alarm'
end as status,
case
when (attributes_std -> 'retention_policy' ->> 'enabled')::boolean and (attributes_std -> 'retention_policy' ->> 'days')::int < 365 then ' retention policy enabled but set to ' || (attributes_std -> 'retention_policy' ->> 'days') || ' days'
when (attributes_std -> 'retention_policy' ->> 'enabled')::boolean and (attributes_std -> 'retention_policy' ->> 'days')::int >= 365 then ' retention policy enabled and set to ' || (attributes_std -> 'retention_policy' ->> 'days') || ' days.'
else ' retention policy disabled'
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type = 'azurerm_monitor_log_profile';

Tags