turbot/steampipe-mod-terraform-azure-compliance

Control: Long-term geo-redundant backup should be enabled for Azure SQL Databases

Description

This policy audits any Azure SQL Database with long-term geo-redundant backup not enabled.

Usage

Run the control in your terminal:

powerpipe control run terraform_azure_compliance.control.sql_database_long_term_geo_redundant_backup_enabled

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std -> 'long_term_retention_policy') is null then 'alarm'
when (attributes_std -> 'long_term_retention_policy' ->> 'monthly_retention')::text <> 'PT0S'
or (attributes_std -> 'long_term_retention_policy' ->> 'weekly_retention')::text <> 'PT0S'
or (attributes_std -> 'long_term_retention_policy' ->> 'yearly_retention')::text <> 'PT0S'
then 'ok'
else 'alarm'
end status,
split_part(address, '.', 2) || case
when (attributes_std -> 'long_term_retention_policy') is null then ' ''long_term_retention_policy'' is not set'
when (attributes_std -> 'long_term_retention_policy' ->> 'monthly_retention')::text <> 'PT0S'
or (attributes_std -> 'long_term_retention_policy' ->> 'weekly_retention')::text <> 'PT0S'
or (attributes_std -> 'long_term_retention_policy' ->> 'yearly_retention')::text <> 'PT0S'
then ' long-term geo-redundant backup enabled'
else ' long-term geo-redundant backup disabled'
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type = 'azurerm_mssql_database';

Tags