turbot/aws_insights

Query: s3_buckets_for_cloudfront_distribution

Usage

powerpipe query aws_insights.query.s3_buckets_for_cloudfront_distribution

SQL

select
arn as bucket_arn
from
aws_s3_bucket
where
name in
(
select distinct
split_part(origin ->> 'DomainName', '.', 1) as bucket_name
from
aws_cloudfront_distribution,
jsonb_array_elements(origins) as origin
where
origin ->> 'DomainName' like '%s3%'
and arn = $1
and account_id = split_part($1,':',5)
);