次のページを参考にしました。
AWS CLI を使用した基本的な Kinesis Data Stream オペレーションの実行
ストリームを作成
STREAM_NAME="sample_sep16"
aws kinesis create-stream --stream-name $STREAM_NAME --shard-count 1
ストリームをリスト
aws kinesis list-streams
詳細を表示
STREAM_NAME="sample_sep16"
aws kinesis describe-stream-summary --stream-name $STREAM_NAME
レコードを3つ入れる
#
STREAM_NAME="sample_sep16"
aws kinesis put-record --stream-name $STREAM_NAME --partition-key 123 --data testdata-aa
aws kinesis put-record --stream-name $STREAM_NAME --partition-key 456 --data testdata-bb
aws kinesis put-record --stream-name $STREAM_NAME --partition-key 789 --data testdata-cc
#
レコードを取り出す
#
SHARD_ITERATOR=`aws kinesis get-shard-iterator --shard-id shardId-000000000000 --shard-iterator-type TRIM_HORIZON --stream-name sample_sep16 | jq .ShardIterator`
#
#
echo $SHARD_ITERATOR
#
aws kinesis get-records --shard-iterator $SHARD_ITERATOR
ストリームの削除
STREAM_NAME="sample_sep16"
aws kinesis delete-stream --stream-name $STREAM_NAME
複数のレコードを一度に入れる方法
aws kinesis put-records --cli-input-json file://in01.json
in01.json
{
"Records": [
{
"Data": "testdata-aa",
"PartitionKey": "123"
},
{
"Data": "testdata-bb",
"PartitionKey": "456"
},
{
"Data": "testdata-cc",
"PartitionKey": "789"
}
],
"StreamName": "sample_sep16"
}