Control: Ensure KMS encryption keys are rotated within a period of 90 days
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. For the gcloud command-line tool, the next rotation time must be in ISO or RFC3339 format, and the rotation period must be in the form INTEGER[UNIT], where units can be one of seconds (s), minutes (m), hours (h) or days (d).
Usage
Run the control in your terminal:
powerpipe control run terraform_gcp_compliance.control.kms_key_rotated_within_90_day
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run terraform_gcp_compliance.control.kms_key_rotated_within_90_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(coalesce((attributes_std ->> 'rotation_period'), ''), 's', 1) :: int <= 7776000 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_linefrom terraform_resourcewhere type = 'google_kms_crypto_key';