turbot/aws_insights

Query: ec2_classic_load_balancers_for_ec2_instance

Usage

powerpipe query aws_insights.query.ec2_classic_load_balancers_for_ec2_instance

SQL

with aws_ec2_instances as (
select
instance_id,
account_id,
region
from
aws_ec2_instance
where
account_id = split_part($1, ':', 5)
and region = split_part($1, ':', 4)
and arn = $1
),
aws_ec2_classic_load_balancers as (
select
arn,
instances,
region,
account_id
from
aws_ec2_classic_load_balancer
where
account_id = split_part($1, ':', 5)
and region = split_part($1, ':', 4)
)
select
distinct clb.arn as classic_load_balancer_arn
from
aws_ec2_classic_load_balancers as clb,
jsonb_array_elements(clb.instances) as instance,
aws_ec2_instances as i
where
instance ->> 'InstanceId' = i.instance_id;