turbot/steampipe-mod-terraform-gcp-compliance

Control: Ensure that there are only GCP-managed service account keys for each service account

Description

User-managed service accounts should not have user-managed keys. It is recommended that only GCP-managed service account keys are used for each service account.

Usage

Run the control in your terminal:

powerpipe control run terraform_gcp_compliance.control.iam_service_account_gcp_managed_key

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
address as resource,
case
when name in (select split_part((attributes_std ->> 'service_account_id'), '.', 2) from terraform_resource where type = 'google_service_account_key') then 'alarm'
else 'ok'
end status,
split_part(address, '.', 2) || case
when name in (select split_part((attributes_std ->> 'service_account_id'), '.', 2) from terraform_resource where type = 'google_service_account_key') then ' has user-managed keys'
else ' does not have user-managed keys'
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type = 'google_service_account';

Tags