turbot/steampipe-mod-terraform-gcp-compliance

Control: Ensure 'log_parser_stats' database flag for Cloud SQL PostgreSQL instance is set to 'off'

Description

The PostgreSQL planner/optimizer is responsible to parse and verify the syntax of each query received by the server. If the syntax is correct, a parse tree is built up else an error is generated. The log_parser_stats flag controls the inclusion of parser performance statistics in the PostgreSQL logs for each query.

Usage

Run the control in your terminal:

powerpipe control run terraform_gcp_compliance.control.sql_instance_postgresql_log_parser_stats_database_flag_off

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run terraform_gcp_compliance.control.sql_instance_postgresql_log_parser_stats_database_flag_off --share

SQL

This control uses a named query:

select
address as resource,
case
when coalesce(trim((attributes_std ->> 'database_version')), '') = '' then 'alarm'
when (attributes_std ->> 'database_version') not like 'POSTGRES%' then 'skip'
when (attributes_std -> 'settings' -> 'database_flags' ->> 'name') = 'log_parser_stats' and
(attributes_std -> 'settings' -> 'database_flags' ->> 'value') = 'off'
then 'ok'
else 'alarm'
end as status,
split_part(address, '.', 2) || case
when coalesce(trim((attributes_std ->> 'database_version')), '') = ''
then ' ''database_version'' is not defined'
when (attributes_std ->> 'database_version') not like 'POSTGRES%'
then ' not a PostgreSQL database'
when (attributes_std -> 'settings') is null then ' ''settings'' is not defined'
when (attributes_std -> 'settings' -> 'database_flags') is null then ' ''settings.database_flags'' is not defined'
when coalesce(trim((attributes_std -> 'settings' -> 'database_flags' ->> 'name')), '') = ''
then ' ''settings.database_flags.name'' is not defined'
when coalesce(trim((attributes_std -> 'settings' -> 'database_flags' ->> 'value')), '') = ''
then ' ''settings.database_flags.value'' is not defined'
when (attributes_std -> 'settings' -> 'database_flags' ->> 'name') <> 'log_parser_stats'
then ' ''log_parser_stats'' database flag not set'
when (attributes_std -> 'settings' -> 'database_flags' ->> 'name') = 'log_parser_stats' and
(attributes_std -> 'settings' -> 'database_flags' ->> 'value') = 'off'
then ' ''log_parser_stats'' database flag set to ''off'''
else ' ''log_parser_stats'' database flag set to ''on'''
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type = 'google_sql_database_instance';

Tags