turbot/steampipe-mod-terraform-gcp-compliance

Control: Ensure that retention policies on log buckets are configured using Bucket Lock

Description

Enabling retention policies on log buckets will protect logs stored in cloud storage buckets from being overwritten or accidentally deleted. It is recommended to set up retention policies and configure Bucket Lock on all storage buckets that are used as log sinks.

Usage

Run the control in your terminal:

powerpipe control run terraform_gcp_compliance.control.logging_bucket_retention_policy_enabled

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std -> 'retention_policy' ->> 'is_locked')::boolean then 'ok' else 'alarm'
end as status,
split_part(address, '.', 2) || case
when (attributes_std -> 'retention_policy') is null then ' ''retention_policy'' is not defined'
when (attributes_std -> 'retention_policy' ->> 'is_locked') is null then ' ''retention_policy.is_locked'' is not defined'
when (attributes_std -> 'retention_policy' ->> 'is_locked')::boolean then ' has retention policies configured'
else ' does not have retention policies configured.'
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type = 'google_storage_bucket';

Tags