turbot/terraform_azure_compliance

Query: network_security_group_subnet_associated

Usage

powerpipe query terraform_azure_compliance.query.network_security_group_subnet_associated

Steampipe Tables

SQL

with all_subnet as (
select
*
from
terraform_resource
where
type = 'azurerm_subnet'
), network_security_group_association as (
select
*
from
terraform_resource
where
type = 'azurerm_subnet_network_security_group_association'
)
select
a.address as resource,
case
when (s.attributes_std ->> 'subnet_id') is not null then 'ok'
else 'alarm'
end as status,
split_part(a.address, '.', 2) || case
when (s.attributes_std ->> 'subnet_id') is not null then ' associated with subnet'
else ' not associated with subnet'
end || '.' reason
, a.path || ':' || a.start_line
from
all_subnet as a
left join network_security_group_association as s on a.name = ( split_part((s.attributes_std ->> 'subnet_id'), '.', 2));

Controls

The query is being used by the following controls: