turbot/aws_insights

Query: ec2_application_load_balancers_for_cloudfront_distribution

Usage

powerpipe query aws_insights.query.ec2_application_load_balancers_for_cloudfront_distribution

SQL

with distribution_origins as (
select
jsonb_array_elements(origins) ->> 'DomainName' as domain_name
from
aws_cloudfront_distribution
where
arn = $1
and account_id = split_part($1,':',5)
),
linked_albs as (
select
b.arn as alb_arn,
b.dns_name
from
aws_ec2_application_load_balancer b
join
distribution_origins d on b.dns_name = d.domain_name
where
b.account_id = split_part($1,':',5)
)
select
alb_arn
from
linked_albs
where
alb_arn is not null;