0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Kinesis Data Stream の使い方

Last updated at Posted at 2021-09-16

次のページを参考にしました。
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"
} 
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?