turbot/gcp_labels
GitHub
Loading controls...

Control: Bigtable instances should have mandatory labels

Description

Check if Bigtable instances have mandatory labels.

Usage

Run the control in your terminal:

steampipe check gcp_labels.control.bigtable_instance_mandatory

Snapshot and share results via Steampipe Cloud:

steampipe login
steampipe check --share gcp_labels.control.bigtable_instance_mandatory

Plugins & Tables

Params

ArgsNameDefaultDescriptionVariable
$1mandatory_labels
["Environment","Owner"]

SQL

with analysis as (
select
self_link,
title,
labels ? & $1 as has_mandatory_labels,
to_jsonb($1) - array(
select
jsonb_object_keys(labels)
) as missing_labels,
location,
project
from
gcp_bigtable_instance
)
select
self_link as resource,
case
when has_mandatory_labels then 'ok'
else 'alarm'
end as status,
case
when has_mandatory_labels then title || ' has all mandatory labels.'
else title || ' is missing labels: ' || array_to_string(
array(
select
jsonb_array_elements_text(missing_labels)
),
', '
) || '.'
end as reason,
location,
project
from
analysis