turbot/azure_tags
GitHub
Loading controls...

Control: Network security groups should have mandatory tags

Description

Check if Network security groups have mandatory tags.

Usage

Run the control in your terminal:

steampipe check azure_tags.control.network_security_group_mandatory

Snapshot and share results via Steampipe Cloud:

steampipe login
steampipe check --share azure_tags.control.network_security_group_mandatory

Plugins & Tables

Params

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

SQL

with analysis as (
select
id,
title,
tags ? & $1 as has_mandatory_tags,
to_jsonb($1) - array(
select
jsonb_object_keys(tags)
) as missing_tags,
resource_group,
subscription_id
from
azure_network_security_group
)
select
id as resource,
case
when has_mandatory_tags then 'ok'
else 'alarm'
end as status,
case
when has_mandatory_tags then title || ' has all mandatory tags.'
else title || ' is missing tags: ' || array_to_string(
array(
select
jsonb_array_elements_text(missing_tags)
),
', '
) || '.'
end as reason,
resource_group,
subscription_id
from
analysis;