turbot/azure_insights

Query: network_load_balancers_for_compute_virtual_machine

Usage

powerpipe query azure_insights.query.network_load_balancers_for_compute_virtual_machine

SQL

with network_interface as (
select
vm.id,
nic.id,
nic.ip_configurations as ip_configurations
from
azure_compute_virtual_machine as vm,
jsonb_array_elements(network_interfaces) as n
left join azure_network_interface as nic on nic.id = n ->> 'id'
where
lower(vm.id) = $1
and vm.subscription_id = split_part($1, '/', 3)
),
loadBalancerBackendAddressPools as (
select
p ->> 'id' as id
from
network_interface,
jsonb_array_elements(ip_configurations) as i,
jsonb_array_elements(i -> 'properties' -> 'loadBalancerBackendAddressPools') as p
)
select
lower(lb.id) as load_balancer_id
from
azure_lb as lb,
jsonb_array_elements(backend_address_pools) as pool
where
lower(pool ->> 'id') in (select lower(id) from loadBalancerBackendAddressPools);