turbot/steampipe-mod-gcp-compliance

Control: Ensure that the 'log_temp_files' database flag for Cloud SQL PostgreSQL instance is set to '0'

Description

PostgreSQL can create a temporary file for actions such as sorting, hashing and temporary query results when these operations exceed work_mem. The log_temp_files flag controls logging names and the file size when it is deleted. Configuring log_temp_files to 0 causes all temporary file information to be logged, while positive values log only files whose size is greater than or equal to the specified number of kilobytes. A value of -1 disables temporary file information logging.

Usage

Run the control in your terminal:

powerpipe control run gcp_compliance.control.sql_instance_postgresql_log_temp_files_database_flag_0

Snapshot and share results via Turbot Pipes:

powerpipe login
powerpipe control run gcp_compliance.control.sql_instance_postgresql_log_temp_files_database_flag_0 --share

SQL

This control uses a named query:

select
self_link resource,
case
when database_version not like 'POSTGRES%' then 'skip'
when database_flags @> '[{"name":"log_temp_files","value":"0"}]' then 'ok'
else 'alarm'
end as status,
case
when database_version not like 'POSTGRES%'
then title || ' not a PostgreSQL database.'
when database_flags is null or not (database_flags @> '[{"name":"log_temp_files"}]')
then title || ' ''log_temp_files'' database flag not set.'
when database_flags @> '[{"name":"log_temp_files","value":"0"}]'
then title || ' ''log_temp_files'' database flag set to ''0''.'
else title || ' ''log_temp_files'' database flag not set to ''0''.'
end as reason
, location as location, project as project
from
gcp_sql_database_instance;

Tags