In this section, we will implement a Kinesis Stream and familiarize ourselves with a few useful Kinesis CLI commands.
- Log into the AWS Management Console and go to Amazon Kinesis Console. Click on the Get started button:
- Click on the Create data stream button on the Get started with Amazon Kinesis screen:
- Specify a name for the Kinesis stream as KinesisTestStream :
Specify the Number of shards as 1. Click on the Create Kinesis stream button:
- You should temporarily see the Status as CREATING, as shown in the following screenshot:
- After the stream is created, you should see a success message, as shown in the following screenshot:
The Status of the Kinesis stream will change to ACTIVE.
- Select the Kinesis stream and then click on Details from the Actions menu:
- View the details of the Kinesis stream you just created in the Details tab:
- Execute the describe-stream command to display the details of the Kinesis stream:
Aurobindos-MacBook-Pro-2:Downloads aurobindosarkar$ aws kinesis describe-stream --stream-name KinesisTestStream
- You can list all your Kinesis streams with the list-streams command:
Aurobindos-MacBook-Pro-2:Downloads aurobindosarkar$ aws kinesis list-streams
- Insert a test record with the put-record command:
Aurobindos-MacBook-Pro-2:Downloads aurobindosarkar$ aws kinesis put-record --stream-name KinesisTestStream --partition-key 123 --data "Test Event Record"
- Use the get-shard-iterator to get the Shard Iterator and copy its value:
Aurobindos-MacBook-Pro-2:Downloads aurobindosarkar$ aws kinesis get-shard-iterator --shard-id shardId-000000000000 --shard-iterator-type TRIM_HORIZON --stream-name KinesisTestStream
{
"ShardIterator": "AAAAAAAAAAGBmIC9k7uah4A0bb0oCW2QfniIesq8snvGJjvlu6D6/UyejLbcjUZK/hzRmSnJtTlQpVpInUoOvacIavV0f4/7X4UE9637qgQi9lc5UqrzXfXKs1Yl4H1Cmp97LD1si3LqqClCsWebTGW8+YUlWFXKfm0kle270c/gcFUqHsxlqyV1XH7XnsY7JVF+0opxvWNygX0Gce0ld4xmCYJ4RPNX"
}
- Use the get-records command (with the shard iterator value) to display the records:
Aurobindos-MacBook-Pro-2:Downloads aurobindosarkar$ aws kinesis get-records --shard-iterator AAAAAAAAAAFn2BntwTpAyLoy9V1e1pQ9OiPz44MAMq+fXKPvG/S0eLoKaeuy/NDWq407234Oc1UgtS5rNOjwN+Zz0YSLDKgSmG/muEwi9ZAA+b91WxjZGatpMTHmizMIdYHkWvLvltzFDbCd/ezoOeE3t2kWWFz0ospxacohJxWicFOnuTrAXymSpaUdWCL5junBCwQ78h4t5v3E38P+zbYbh9OYgy4o