Skip to content

Instantly share code, notes, and snippets.

@amcginlay
Last active November 11, 2019 12:14
Show Gist options
  • Save amcginlay/de1ce820c10684fbe7b75e8fe1ce339e to your computer and use it in GitHub Desktop.
Save amcginlay/de1ce820c10684fbe7b75e8fe1ce339e to your computer and use it in GitHub Desktop.
Kinesis data stream demo
# assumes a data stream named "demo-stream" with one shard exists
# inspect data stream and copy identity SHARD_ID variable (e.g. ShardId-????)
aws kinesis list-streams
STREAM_NAME=demo-stream
aws kinesis describe-stream --stream-name ${STREAM_NAME}
SHARD_ID=shardId-000000000000
# add four records
aws kinesis put-record --stream-name ${STREAM_NAME} --partition-key 1 --data 1
aws kinesis put-record --stream-name ${STREAM_NAME} --partition-key 2 --data 2
aws kinesis put-record --stream-name ${STREAM_NAME} --partition-key 3 --data 3
aws kinesis put-record --stream-name ${STREAM_NAME} --partition-key 4 --data 4
# get shard iterator and copy result to SHARD_ITERATOR variable
aws kinesis get-shard-iterator --stream-name ${STREAM_NAME} --shard-id ${SHARD_ID} --shard-iterator-type TRIM_HORIZON
# get two records, decode a data value and note the NEXT_SHARD_ITERATOR
aws kinesis get-records --shard-iterator ${SHARD_ITERATOR} --limit 2
echo ${SOME_DATA_VALUE} | base64 --decode
aws kinesis get-records --shard-iterator ${NEXT_SHARD_ITERATOR} --limit 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment