turbot/terraform_gcp_compliance

Query: sql_instance_postgresql_log_min_error_statement_flag_set

Usage

powerpipe query terraform_gcp_compliance.query.sql_instance_postgresql_log_min_error_statement_flag_set

Steampipe Tables

SQL

select
address as resource,
case
when jsonb_typeof(attributes_std -> 'settings' -> 'database_flags') = 'object'
and (
attributes_std -> 'settings' -> 'database_flags' ->> 'name'
) = 'log_min_error_statement'
and (
attributes_std -> 'settings' -> 'database_flags' ->> 'value'
) in (
'debug5',
'debug4',
'debug3',
'debug2',
'debug1',
'info',
'notice',
'warning',
'error'
) then 'ok'
when jsonb_typeof(attributes_std -> 'settings' -> 'database_flags') = 'array'
and exists(
select
1
from
jsonb_array_elements(attributes_std -> 'settings' -> 'database_flags') as flags
where
(flags ->> 'name') = 'log_min_error_statement'
and (flags ->> 'value') in (
'debug5',
'debug4',
'debug3',
'debug2',
'debug1',
'info',
'notice',
'warning',
'error'
)
) then 'ok'
else 'alarm'
end as status,
split_part(address, '.', 2) || case
when jsonb_typeof(attributes_std -> 'settings' -> 'database_flags') = 'object'
and (
attributes_std -> 'settings' -> 'database_flags' ->> 'name'
) = 'log_min_error_statement'
and (
attributes_std -> 'settings' -> 'database_flags' ->> 'value'
) in (
'debug5',
'debug4',
'debug3',
'debug2',
'debug1',
'info',
'notice',
'warning',
'error'
) then ' log min error statement database flag value set to debug5, debug4, debug3, debug2, debug1, info, notice, warning, error'
when jsonb_typeof(attributes_std -> 'settings' -> 'database_flags') = 'array'
and exists(
select
1
from
jsonb_array_elements(attributes_std -> 'settings' -> 'database_flags') as flags
where
(flags ->> 'name') = 'log_min_error_statement'
and (flags ->> 'value') in (
'debug5',
'debug4',
'debug3',
'debug2',
'debug1',
'info',
'notice',
'warning',
'error'
)
) then ' log min error statement database flag value set to debug5, debug4, debug3, debug2, debug1, info, notice, warning, error'
else ' log min error statement database flag value not set'
end || '.' reason,
path || ':' || start_line
from
terraform_resource
where
type = 'google_sql_database_instance'
and (attributes_std ->> 'database_version') like 'POSTGRES%';

Controls

The query is being used by the following controls: