turbot/aws_insights

Query: kms_keys_for_sqs_queue

Usage

powerpipe query aws_insights.query.kms_keys_for_sqs_queue

Steampipe Tables

SQL

with sqs_queue as (
select
kms_master_key_id,
queue_arn,
region,
account_id
from
aws_sqs_queue
where
account_id = split_part($1, ':', 5)
and region = split_part($1, ':', 4)
and queue_arn = $1
order by
queue_arn,
region,
account_id
), kms_keys as (
select
aliases,
arn,
region,
account_id
from
aws_kms_key
where
account_id = split_part($1, ':', 5)
and region = split_part($1, ':', 4)
order by
region,
account_id
)
select
k.arn as key_arn
from
sqs_queue as q,
kms_keys as k,
jsonb_array_elements(aliases) as a
where
a ->> 'AliasName' = q.kms_master_key_id
and k.region = q.region
and k.account_id = q.account_id;