Last active
August 19, 2019 09:06
-
-
Save oripwk/f9da4d2ae727359c2de11a1bc5f0d2d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then | |
echo "usage: kinesis-tail <profile> <stream-name> <iterator-type> [region]" | |
exit 1 | |
fi | |
if [ -n "$4" ]; then | |
export AWS_DEFAULT_REGION=$4 | |
fi | |
export AWS_PROFILE=$1 | |
streamname=$2 | |
type=$3 | |
aws kinesis describe-stream --stream-name $streamname --query StreamDescription.Shards[].{shard:ShardId} --output text | while read shard; do aws kinesis get-shard-iterator --stream-name $streamname --shard-id $shard --shard-iterator-type LATEST --output text | while read iterator; do while output=`aws kinesis get-records --shard-iterator $iterator --output text`; do iterator=`echo "$output" | head -n1 | awk '{print $2}'`; echo "$output" | gsed 1d | grep RECORDS | while read record; do echo $record | awk '{print $3}' | base64 -D; done; done; done; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment