turbot/aws_insights

Query: kinesis_streams_for_dynamodb_table

Usage

powerpipe query aws_insights.query.kinesis_streams_for_dynamodb_table

SQL

with dynamodb_details as (
select
arn,
region,
account_id,
jsonb_array_elements(streaming_destination -> 'KinesisDataStreamDestinations') as destination
from
aws_dynamodb_table
where
arn = $1
and region = split_part($1, ':', 4)
and account_id = split_part($1, ':', 5)
),
kinesis_stream_details as (
select
stream_arn
from
aws_kinesis_stream
where
region = split_part($1, ':', 4)
and account_id = split_part($1, ':', 5)
)
select
ksd.stream_arn as kinesis_stream_arn
from
kinesis_stream_details ksd
join
dynamodb_details dd on dd.destination ->> 'StreamArn' = ksd.stream_arn;