turbot/gcp_insights

Query: compute_subnets_for_compute_instance

Usage

powerpipe query gcp_insights.query.compute_subnets_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_subnetwork as (
select
self_link,
id,
project
from
gcp_compute_subnetwork
)
select
s.id::text || '/' || s.project as subnetwork_id
from
compute_instance i,
compute_subnetwork s,
jsonb_array_elements(network_interfaces) as ni
where
ni ->> 'subnetwork' = s.self_link;