turbot/aws_insights

Query: s3_buckets_for_kms_key

Usage

powerpipe query aws_insights.query.s3_buckets_for_kms_key

Steampipe Tables

SQL

select
b.arn as bucket_arn
from
aws_s3_bucket as b
cross join jsonb_array_elements(server_side_encryption_configuration -> 'Rules') as r
join aws_kms_key as k
on k.arn = r -> 'ApplyServerSideEncryptionByDefault' ->> 'KMSMasterKeyID'
where
k.arn = $1
and k.region = split_part($1, ':', 4)
and k.account_id = split_part($1, ':', 5);