turbot/steampipe-mod-terraform-gcp-compliance

Control: Ensure that users are not assigned the Service Account User or Service Account Token Creator roles at project level

Description

This control checks that users are not assigned the Service Account User or Service Account Token Creator roles at the project level.

Usage

Run the control in your terminal:

powerpipe control run terraform_gcp_compliance.control.iam_project_no_service_account_token_creator_role

Snapshot and share results via Turbot Pipes:

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

SQL

This control uses a named query:

select
address as resource,
case
when (attributes_std ->> 'role') like any (array ['roles/iam.serviceAccountUser', 'roles/iam.serviceAccountTokenCreator']) then 'alarm'
else 'ok'
end status,
split_part(address, '.', 2) || case
when (attributes_std ->> 'role') like any (array ['roles/iam.serviceAccountUser', 'roles/iam.serviceAccountTokenCreator']) then ' service account roles assigned'
else ' no service account roles assigned'
end || '.' reason
, path || ':' || start_line
from
terraform_resource
where
type in ('google_project_iam_member', 'google_project_iam_binding');

Tags