Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions,
see Getting Started with Amazon Web Services in China
(PDF).
Use GetShardIterator
with a CLI
The following code examples show how to use GetShardIterator
.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in
context in the following code example:
- CLI
-
- Amazon CLI
-
To obtain a shard iterator
The following get-shard-iterator
example uses the AT_SEQUENCE_NUMBER
shard iterator type and generates a shard iterator to start reading data records exactly from the position denoted by the specified sequence number.
aws kinesis get-shard-iterator \
--stream-name samplestream
\
--shard-id shardId-000000000001
\
--shard-iterator-type LATEST
Output:
{
"ShardIterator": "AAAAAAAAAAFEvJjIYI+3jw/4aqgH9FifJ+n48XWTh/IFIsbILP6o5eDueD39NXNBfpZ10WL5K6ADXk8w+5H+Qhd9cFA9k268CPXCz/kebq1TGYI7Vy+lUkA9BuN3xvATxMBGxRY3zYK05gqgvaIRn94O8SqeEqwhigwZxNWxID3Ej7YYYcxQi8Q/fIrCjGAy/n2r5Z9G864YpWDfN9upNNQAR/iiOWKs"
}
For more information, see Developing Consumers Using the Kinesis Data Streams API with the Amazon SDK for Java in the Amazon Kinesis Data Streams Developer Guide.
- PowerShell
-
- Tools for PowerShell
-
Example 1: Returns a shard iterator for the specified shard and starting position. Details of the shard identifiers and sequence numbers can be obtained from the output of the Get-KINStream cmdlet, by referencing the Shards collection of the returned stream object. The returned iterator can be used with the Get-KINRecord cmdlet to pull data records in the shard.
Get-KINShardIterator -StreamName "mystream" -ShardId "shardId-000000000000" -ShardIteratorType AT_SEQUENCE_NUMBER -StartingSequenceNumber "495598645..."
Output:
AAAAAAAAAAGIc....9VnbiRNaP
For a complete list of Amazon SDK developer guides and code examples, see
Using this service with an Amazon SDK.
This topic also includes information about getting started and details about previous SDK versions.