turbot/gcp_insights

Query: compute_firewalls_for_compute_instance

Usage

powerpipe query gcp_insights.query.compute_firewalls_for_compute_instance

SQL

with compute_instance as (
select
id,
network_interfaces
from
gcp_compute_instance
where
id = (split_part($1, '/', 1))::bigint
and project = split_part($1, '/', 2)
), compute_firewall as (
select
network,
id
from
gcp_compute_firewall
)
select
f.id::text as firewall_id
from
compute_instance i,
compute_firewall f,
jsonb_array_elements(network_interfaces) as ni
where
ni ->> 'network' = f.network;