- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
GetShardIteratorCommand
Returns a shard iterator. A shard iterator provides information about how to retrieve the stream records from within a shard. Use the shard iterator in a subsequent GetRecords
request to read the stream records from the shard.
A shard iterator expires 15 minutes after it is returned to the requester.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { DynamoDBStreamsClient, GetShardIteratorCommand } from "@aws-sdk/client-dynamodb-streams"; // ES Modules import
// const { DynamoDBStreamsClient, GetShardIteratorCommand } = require("@aws-sdk/client-dynamodb-streams"); // CommonJS import
const client = new DynamoDBStreamsClient(config);
const input = { // GetShardIteratorInput
StreamArn: "STRING_VALUE", // required
ShardId: "STRING_VALUE", // required
ShardIteratorType: "TRIM_HORIZON" || "LATEST" || "AT_SEQUENCE_NUMBER" || "AFTER_SEQUENCE_NUMBER", // required
SequenceNumber: "STRING_VALUE",
};
const command = new GetShardIteratorCommand(input);
const response = await client.send(command);
// { // GetShardIteratorOutput
// ShardIterator: "STRING_VALUE",
// };
Example Usage
GetShardIteratorCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
ShardId Required | string | undefined | The identifier of the shard. The iterator will be returned for this shard ID. |
ShardIteratorType Required | ShardIteratorType | undefined | Determines how the shard iterator is used to start reading stream records from the shard:
|
StreamArn Required | string | undefined | The Amazon Resource Name (ARN) for the stream. |
SequenceNumber | string | undefined | The sequence number of a stream record in the shard from which to start reading. |
GetShardIteratorCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
ShardIterator | string | undefined | The position in the shard from which to start reading stream records sequentially. A shard iterator specifies this position using the sequence number of a stream record in a shard. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InternalServerError | server | An error occurred on the server side. |
ResourceNotFoundException | client | The operation tried to access a nonexistent table or index. The resource might not be specified correctly, or its status might not be |
TrimmedDataAccessException | client | The operation attempted to read past the oldest stream record in a shard. In DynamoDB Streams, there is a 24 hour limit on data retention. Stream records whose age exceeds this limit are subject to removal (trimming) from the stream. You might receive a TrimmedDataAccessException if:
|
DynamoDBStreamsServiceException | Base exception class for all service exceptions from DynamoDBStreams service. |