turbot/gcp_insights

Query: compute_instance_groups_for_compute_instance

Usage

powerpipe query gcp_insights.query.compute_instance_groups_for_compute_instance

SQL

with compute_instance as (
select
id,
self_link
from
gcp_compute_instance
where
id = (split_part($1, '/', 1))::bigint
and project = split_part($1, '/', 2)
), compute_instance_group as (
select
id,
instances,
project
from
gcp_compute_instance_group
)
select
g.id::text || '/' || g.project as group_id
from
compute_instance as ins,
compute_instance_group as g,
jsonb_array_elements(instances) as i
where
(i ->> 'instance') = ins.self_link;