Control: Check if service account keys are older than 100 days
Usage
Run the control in your terminal:
powerpipe control run gcp_compliance.control.iam_restrict_service_account_key_age_one_hundred_days
Snapshot and share results via Turbot Pipes:
powerpipe loginpowerpipe control run gcp_compliance.control.iam_restrict_service_account_key_age_one_hundred_days --share
SQL
This control uses a named query:
select 'https://iam.googleapis.com/v1/projects/' || project || '/serviceAccounts/' || service_account_name || '/keys/' || name as resource, case when valid_after_time <= (current_date - interval '100' day) then 'alarm' else 'ok' end as status, service_account_name || ' ' || name || ' created ' || to_char(valid_after_time , 'DD-Mon-YYYY') || ' (' || extract(day from current_timestamp - valid_after_time) || ' days).' as reason , project as projectfrom gcp_service_account_key;