turbot/steampipe-mod-terraform-gcp-compliance

Control: Check that CMEK rotation policy is in place and is sufficiently short

Description

Google Cloud Key Management Service stores cryptographic keys in a hierarchical structure designed for useful and elegant access control management. The format for the rotation schedule depends on the client library that is used.

Usage

Run the control in your terminal:

powerpipe control run terraform_gcp_compliance.control.kms_key_rotated_within_100_day

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
address as resource,
case
when coalesce((attributes_std ->> 'rotation_period'), '') = '' then 'alarm'
when split_part((attributes_std ->> 'rotation_period'), 's', 1) :: int <= 8640000 then 'ok'
else 'alarm'
end as status,
split_part(address, '.', 2) || case
when coalesce((attributes_std ->> 'rotation_period'), '') = '' then ' requires manual rotation'
else ' rotation period set for ' || (split_part((attributes_std ->> 'rotation_period'), 's', 1) :: int)/86400 || ' day(s)'
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type = 'google_kms_crypto_key';

Tags