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_enabledSnapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_azure_compliance.control.sql_database_long_term_geo_redundant_backup_enabled --shareSQL
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_linefrom  terraform_resourcewhere  type = 'azurerm_mssql_database';