turbot/gcp_insights

Query: compute_networks_for_compute_instance

Usage

powerpipe query gcp_insights.query.compute_networks_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_network as (
select
self_link,
id,
project
from
gcp_compute_network
)
select
n.id::text || '/' || n.project as network_id
from
compute_instance i,
compute_network n,
jsonb_array_elements(network_interfaces) as ni
where
ni ->> 'network' = n.self_link;