Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
    • Yandex Cloud Partner program
  • Blog
  • Pricing
  • Documentation
© 2025 Direct Cursus Technology L.L.C.
Yandex Data Streams
    • All guides
    • Managing data streams
      • Creating a stream
      • Getting stream information
      • Sending data to a stream
      • Reading data from a stream
      • Deleting a stream
  • Access management
  • Pricing policy
  • FAQ
  1. Step-by-step guides
  2. Working with the AWS CLI
  3. Reading data from a stream

Reading data from a stream in the AWS CLI

Written by
Yandex Cloud
Updated at May 13, 2024
CLI

To get data from a stream's first shard, run the command:

SHARD_ITERATOR=$(aws kinesis get-shard-iterator \
  --endpoint <endpoint> \
  --shard-id shard-000001 \
  --shard-iterator-type LATEST \
  --stream-name <stream_ID> \
  --query 'ShardIterator'| tr -d \")
aws kinesis get-records \
  --endpoint <endpoint> \
  --shard-iterator $SHARD_ITERATOR

Where:

  • --endpoint: To get stream data over the AWS Kinesis Data Streams protocol, specify https://yds.serverless.yandexcloud.net.

  • --stream-name: Consists of the availability zone, folder ID, Yandex Managed Service for YDB database ID, and stream name.

    For example, your stream ID will appear as /ru-central1/aoeu1kuk2dht********/cc8029jgtuab********/aws_stream if:

    • aws_stream: Stream name
    • ru-central1: Region
    • aoeu1kuk2dht********: Folder ID
    • cc8029jgtuab********: YDB database ID

Command example:

SHARD_ITERATOR=$(aws kinesis get-shard-iterator \
  --endpoint https://yds.serverless.yandexcloud.net \
  --shard-id shard-000001 \
  --shard-iterator-type LATEST \
  --stream-name /ru-central1/aoeu1kuk2dht********/cc8029jgtuab********/aws_stream
  --query 'ShardIterator'| tr -d \")
aws kinesis get-records \
  --endpoint https://yds.serverless.yandexcloud.net \
  --shard-iterator $SHARD_ITERATOR

Result example:

{
  "Records": [
      {
          "SequenceNumber": "0",
          "Data": "eyJ1c2VyX2lkIjoidXNlcjEiLCJzY29yZSI6MTAwfQ==",
          "PartitionKey": "1"
      },
      {
          "SequenceNumber": "1",
          "Data": "eyJ1c2VyX2lkIjoidXNlcjEiLCJzY29yZSI6MTAwfQ==",
          "PartitionKey": "1"
      },
  ...
}

In the example above, the data output in the Data field are BASE64-encoded. If you decode it, the following string is returned:

  {"user_id":"user1","score":100}

Was the article helpful?

Previous
Sending data to a stream
Next
Deleting a stream
© 2025 Direct Cursus Technology L.L.C.