turbot/terraform_azure_compliance

Query: network_security_group_not_configured_gateway_subnets

Usage

powerpipe query terraform_azure_compliance.query.network_security_group_not_configured_gateway_subnets

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 (a.attributes_std ->> 'name') :: text = 'GatewaySubnet'
and (s.attributes_std ->> 'subnet_id') is not null then 'alarm'
when (a.attributes_std ->> 'name') :: text = 'GatewaySubnet'
and (s.attributes_std ->> 'subnet_id') is null then 'ok'
else 'skip'
end as status,
split_part(a.address, '.', 2) || case
when (a.attributes_std ->> 'name') :: text = 'GatewaySubnet'
and (s.attributes_std ->> 'subnet_id') is not null then ' Gateway subnet configured with network security group'
when (a.attributes_std ->> 'name') :: text = 'GatewaySubnet'
and (s.attributes_std ->> 'subnet_id') is null then ' Gateway subnet not configured with network security group'
else ' not of gateway subnet type'
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: