Amazon Kinesis

2026/09/01 - Amazon Kinesis - 5 updated api methods

Changes  Amazon Kinesis Data Streams now supports a dry run feature for data-plane APIs to validate the permissions and request parameters. If all checks complete successfully, the API returns a 'DryRunOperationException', confirming the request would have succeeded without the 'DryRun' parameter.

GetRecords (updated) Link ¶
Changes (request)
{'DryRun': 'boolean'}

Gets data records from a Kinesis data stream's shard.

Specify a shard iterator using the ShardIterator parameter. The shard iterator specifies the position in the shard from which you want to start reading data records sequentially. If there are no records available in the portion of the shard that the iterator points to, GetRecords returns an empty list. It might take multiple calls to get to a portion of the shard that contains records.

You can scale by provisioning multiple shards per stream while considering service limits (for more information, see Amazon Kinesis Data Streams Limits in the Amazon Kinesis Data Streams Developer Guide). Your application should have one thread per shard, each reading continuously from its stream. To read from a stream continually, call GetRecords in a loop. Use GetShardIterator to get the shard iterator to specify in the first GetRecords call. GetRecords returns a new shard iterator in NextShardIterator. Specify the shard iterator returned in NextShardIterator in subsequent calls to GetRecords. If the shard has been closed, the shard iterator can't return more data and GetRecords returns null in NextShardIterator. You can terminate the loop when the shard is closed, or when the shard iterator reaches the record with the sequence number or other attribute that marks it as the last record to process.

Each data record can be up to 1 MiB in size by default. Amazon Kinesis Data Streams supports large records up to 10 MiB in size, but the average throughput for your stream cannot exceed 1 MiB per second. For more information about how large records are handled, see Large records. Each shard can read up to 2 MiB per second. You can ensure that your calls don't exceed the maximum supported size or throughput by using the Limit parameter to specify the maximum number of records that GetRecords can return. Consider your average record size when determining this limit. The maximum number of records that can be returned per call is 10,000.

The size of the data returned by GetRecords varies depending on the utilization of the shard. It is recommended that consumer applications retrieve records via the GetRecords command using the 5 TPS limit to remain caught up. Retrieving records less frequently can lead to consumer applications falling behind. The maximum size of data that GetRecords can return is 10 MiB. If a call returns this amount of data, subsequent calls made within the next 5 seconds throw ProvisionedThroughputExceededException. If there is insufficient provisioned throughput on the stream, subsequent calls made within the next 1 second throw ProvisionedThroughputExceededException. GetRecords doesn't return any data when it throws an exception. For this reason, we recommend that you wait 1 second between calls to GetRecords. However, it's possible that the application will get exceptions for longer than 1 second.

To detect whether the application is falling behind in processing, you can use the MillisBehindLatest response attribute. You can also monitor the stream using CloudWatch metrics and other mechanisms (see Monitoring in the Amazon Kinesis Data Streams Developer Guide).

Each Amazon Kinesis record includes a value, ApproximateArrivalTimestamp, that is set when a stream successfully receives and stores a record. This is commonly referred to as a server-side time stamp, whereas a client-side time stamp is set when a data producer creates or sends the record to a stream (a data producer is any data source putting data records into a stream, for example with PutRecords). The time stamp has millisecond precision. There are no guarantees about the time stamp accuracy, or that the time stamp is always increasing. For example, records in a shard or across a stream might have time stamps that are out of order.

This operation has a limit of five transactions per second per shard.

See also: AWS API Documentation

Request Syntax

client.get_records(
    ShardIterator='string',
    Limit=123,
    StreamARN='string',
    StreamId='string',
    DryRun=True|False
)
type ShardIterator:

string

param ShardIterator:

[REQUIRED]

The position in the shard from which you want to start sequentially reading data records. A shard iterator specifies this position using the sequence number of a data record in the shard.

type Limit:

integer

param Limit:

The maximum number of records to return. Specify a value of up to 10,000. If you specify a value that is greater than 10,000, GetRecords throws InvalidArgumentException. The default value is 10,000.

type StreamARN:

string

param StreamARN:

The ARN of the stream.

type StreamId:

string

param StreamId:

Not Implemented. Reserved for future use.

type DryRun:

boolean

param DryRun:

Checks if your request will succeed. DryRun is an optional parameter.

rtype:

dict

returns:

Response Syntax

{
    'Records': [
        {
            'SequenceNumber': 'string',
            'ApproximateArrivalTimestamp': datetime(2015, 1, 1),
            'Data': b'bytes',
            'PartitionKey': 'string',
            'EncryptionType': 'NONE'|'KMS'
        },
    ],
    'NextShardIterator': 'string',
    'MillisBehindLatest': 123,
    'ChildShards': [
        {
            'ShardId': 'string',
            'ParentShards': [
                'string',
            ],
            'HashKeyRange': {
                'StartingHashKey': 'string',
                'EndingHashKey': 'string'
            }
        },
    ]
}

Response Structure

  • (dict) --

    Represents the output for GetRecords.

    • Records (list) --

      The data records retrieved from the shard.

      • (dict) --

        The unit of data of the Kinesis data stream, which is composed of a sequence number, a partition key, and a data blob.

        • SequenceNumber (string) --

          The unique identifier of the record within its shard.

        • ApproximateArrivalTimestamp (datetime) --

          The approximate time that the record was inserted into the stream.

        • Data (bytes) --

          The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not inspect, interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (10 MiB).

        • PartitionKey (string) --

          Identifies which shard in the stream the data record is assigned to.

        • EncryptionType (string) --

          The encryption type used on the record. This parameter can be one of the following values:

          • NONE: Do not encrypt the records in the stream.

          • KMS: Use server-side encryption on the records in the stream using a customer-managed Amazon Web Services KMS key.

    • NextShardIterator (string) --

      The next position in the shard from which to start sequentially reading data records. If set to null, the shard has been closed and the requested iterator does not return any more data.

    • MillisBehindLatest (integer) --

      The number of milliseconds the GetRecords response is from the tip of the stream, indicating how far behind current time the consumer is. A value of zero indicates that record processing is caught up, and there are no new records to process at this moment.

    • ChildShards (list) --

      The list of the current shard's child shards, returned in the GetRecords API's response only when the end of the current shard is reached.

      • (dict) --

        Output parameter of the GetRecords API. The existing child shard of the current shard.

        • ShardId (string) --

          The shard ID of the existing child shard of the current shard.

        • ParentShards (list) --

          The current shard that is the parent of the existing child shard.

          • (string) --

        • HashKeyRange (dict) --

          The range of possible hash key values for the shard, which is a set of ordered contiguous positive integers.

          • StartingHashKey (string) --

            The starting hash key of the hash key range.

          • EndingHashKey (string) --

            The ending hash key of the hash key range.

GetShardIterator (updated) Link ¶
Changes (request)
{'DryRun': 'boolean'}

Gets an Amazon Kinesis shard iterator. A shard iterator expires 5 minutes after it is returned to the requester.

A shard iterator specifies the shard position from which to start reading data records sequentially. The position is specified using the sequence number of a data record in a shard. A sequence number is the identifier associated with every record ingested in the stream, and is assigned when a record is put into the stream. Each stream has one or more shards.

You must specify the shard iterator type. For example, you can set the ShardIteratorType parameter to read exactly from the position denoted by a specific sequence number by using the AT_SEQUENCE_NUMBER shard iterator type. Alternatively, the parameter can read right after the sequence number by using the AFTER_SEQUENCE_NUMBER shard iterator type, using sequence numbers returned by earlier calls to PutRecord, PutRecords, GetRecords, or DescribeStream. In the request, you can specify the shard iterator type AT_TIMESTAMP to read records from an arbitrary point in time, TRIM_HORIZON to cause ShardIterator to point to the last untrimmed record in the shard in the system (the oldest data record in the shard), or LATEST so that you always read the most recent data in the shard.

When you read repeatedly from a stream, use a GetShardIterator request to get the first shard iterator for use in your first GetRecords request and for subsequent reads use the shard iterator returned by the GetRecords request in NextShardIterator. A new shard iterator is returned by every GetRecords request in NextShardIterator, which you use in the ShardIterator parameter of the next GetRecords request.

If a GetShardIterator request is made too often, you receive a ProvisionedThroughputExceededException. For more information about throughput limits, see GetRecords, and Streams Limits in the Amazon Kinesis Data Streams Developer Guide.

If the shard is closed, GetShardIterator returns a valid iterator for the last sequence number of the shard. A shard can be closed as a result of using SplitShard or MergeShards.

GetShardIterator has a limit of five transactions per second per account per open shard.

See also: AWS API Documentation

Request Syntax

client.get_shard_iterator(
    StreamName='string',
    ShardId='string',
    ShardIteratorType='AT_SEQUENCE_NUMBER'|'AFTER_SEQUENCE_NUMBER'|'TRIM_HORIZON'|'LATEST'|'AT_TIMESTAMP',
    StartingSequenceNumber='string',
    Timestamp=datetime(2015, 1, 1),
    StreamARN='string',
    StreamId='string',
    DryRun=True|False
)
type StreamName:

string

param StreamName:

The name of the Amazon Kinesis data stream.

type ShardId:

string

param ShardId:

[REQUIRED]

The shard ID of the Kinesis Data Streams shard to get the iterator for.

type ShardIteratorType:

string

param ShardIteratorType:

[REQUIRED]

Determines how the shard iterator is used to start reading data records from the shard.

The following are the valid Amazon Kinesis shard iterator types:

  • AT_SEQUENCE_NUMBER - Start reading from the position denoted by a specific sequence number, provided in the value StartingSequenceNumber.

  • AFTER_SEQUENCE_NUMBER - Start reading right after the position denoted by a specific sequence number, provided in the value StartingSequenceNumber.

  • AT_TIMESTAMP - Start reading from the position denoted by a specific time stamp, provided in the value Timestamp.

  • TRIM_HORIZON - Start reading at the last untrimmed record in the shard in the system, which is the oldest data record in the shard.

  • LATEST - Start reading just after the most recent record in the shard, so that you always read the most recent data in the shard.

type StartingSequenceNumber:

string

param StartingSequenceNumber:

The sequence number of the data record in the shard from which to start reading. Used with shard iterator type AT_SEQUENCE_NUMBER and AFTER_SEQUENCE_NUMBER.

type Timestamp:

datetime

param Timestamp:

The time stamp of the data record from which to start reading. Used with shard iterator type AT_TIMESTAMP. A time stamp is the Unix epoch date with precision in milliseconds. For example, 2016-04-04T19:58:46.480-00:00 or 1459799926.480. If a record with this exact time stamp does not exist, the iterator returned is for the next (later) record. If the time stamp is older than the current trim horizon, the iterator returned is for the oldest untrimmed data record (TRIM_HORIZON).

type StreamARN:

string

param StreamARN:

The ARN of the stream.

type StreamId:

string

param StreamId:

Not Implemented. Reserved for future use.

type DryRun:

boolean

param DryRun:

Checks if your request will succeed. DryRun is an optional parameter.

rtype:

dict

returns:

Response Syntax

{
    'ShardIterator': 'string'
}

Response Structure

  • (dict) --

    Represents the output for GetShardIterator.

    • ShardIterator (string) --

      The position in the shard from which to start reading data records sequentially. A shard iterator specifies this position using the sequence number of a data record in a shard.

PutRecord (updated) Link ¶
Changes (request)
{'DryRun': 'boolean'}

Writes a single data record into an Amazon Kinesis data stream. Call PutRecord to send data into the stream for real-time ingestion and subsequent processing, one record at a time. Each shard can support writes up to 1,000 records per second, up to a maximum data write total of 10 MiB per second.

You must specify the name of the stream that captures, stores, and transports the data; a partition key; and the data blob itself.

The data blob can be any type of data; for example, a segment from a log file, geographic/location data, website clickstream data, and so on.

The partition key is used by Kinesis Data Streams to distribute data across shards. Kinesis Data Streams segregates the data records that belong to a stream into multiple shards, using the partition key associated with each data record to determine the shard to which a given data record belongs.

Partition keys are Unicode strings, with a maximum length limit of 256 characters for each key. An MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards using the hash key ranges of the shards. You can override hashing the partition key to determine the shard by explicitly specifying a hash value using the ExplicitHashKey parameter. For more information, see Adding Data to a Stream in the Amazon Kinesis Data Streams Developer Guide.

PutRecord returns the shard ID of where the data record was placed and the sequence number that was assigned to the data record.

Sequence numbers increase over time and are specific to a shard within a stream, not across all shards within a stream. To guarantee strictly increasing ordering, write serially to a shard and use the SequenceNumberForOrdering parameter. For more information, see Adding Data to a Stream in the Amazon Kinesis Data Streams Developer Guide.

If a PutRecord request cannot be processed because of insufficient provisioned throughput on the shard involved in the request, PutRecord throws ProvisionedThroughputExceededException.

By default, data records are accessible for 24 hours from the time that they are added to a stream. You can use IncreaseStreamRetentionPeriod or DecreaseStreamRetentionPeriod to modify this retention period.

See also: AWS API Documentation

Request Syntax

client.put_record(
    StreamName='string',
    Data=b'bytes',
    PartitionKey='string',
    ExplicitHashKey='string',
    SequenceNumberForOrdering='string',
    StreamARN='string',
    StreamId='string',
    DryRun=True|False
)
type StreamName:

string

param StreamName:

The name of the stream to put the data record into.

type Data:

bytes

param Data:

[REQUIRED]

The data blob to put into the record, which is base64-encoded when the blob is serialized. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (10 MiB).

type PartitionKey:

string

param PartitionKey:

[REQUIRED]

Determines which shard in the stream the data record is assigned to. Partition keys are Unicode strings with a maximum length limit of 256 characters for each key. Amazon Kinesis Data Streams uses the partition key as input to a hash function that maps the partition key and associated data to a specific shard. Specifically, an MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards. As a result of this hashing mechanism, all data records with the same partition key map to the same shard within the stream.

type ExplicitHashKey:

string

param ExplicitHashKey:

The hash value used to explicitly determine the shard the data record is assigned to by overriding the partition key hash.

type SequenceNumberForOrdering:

string

param SequenceNumberForOrdering:

Guarantees strictly increasing sequence numbers, for puts from the same client and to the same partition key. Usage: set the SequenceNumberForOrdering of record n to the sequence number of record n-1 (as returned in the result when putting record n-1). If this parameter is not set, records are coarsely ordered based on arrival time.

type StreamARN:

string

param StreamARN:

The ARN of the stream.

type StreamId:

string

param StreamId:

Not Implemented. Reserved for future use.

type DryRun:

boolean

param DryRun:

Checks if your request will succeed. DryRun is an optional parameter.

rtype:

dict

returns:

Response Syntax

{
    'ShardId': 'string',
    'SequenceNumber': 'string',
    'EncryptionType': 'NONE'|'KMS'
}

Response Structure

  • (dict) --

    Represents the output for PutRecord.

    • ShardId (string) --

      The shard ID of the shard where the data record was placed.

    • SequenceNumber (string) --

      The sequence number identifier that was assigned to the put data record. The sequence number for the record is unique across all records in the stream. A sequence number is the identifier associated with every record put into the stream.

    • EncryptionType (string) --

      The encryption type to use on the record. This parameter can be one of the following values:

      • NONE: Do not encrypt the records in the stream.

      • KMS: Use server-side encryption on the records in the stream using a customer-managed Amazon Web Services KMS key.

PutRecords (updated) Link ¶
Changes (request)
{'DryRun': 'boolean'}

Writes multiple data records into a Kinesis data stream in a single call (also referred to as a PutRecords request). Use this operation to send data into the stream for data ingestion and processing.

Each PutRecords request can support up to 500 records. Each record in the request can be as large as 10 MiB, up to a limit of 10 MiB for the entire request, including partition keys. Each shard can support writes up to 1,000 records per second, up to a maximum data write total of 1 MB per second.

You must specify the name of the stream that captures, stores, and transports the data; and an array of request Records, with each record in the array requiring a partition key and data blob. The record size limit applies to the total size of the partition key and data blob.

The data blob can be any type of data; for example, a segment from a log file, geographic/location data, website clickstream data, and so on.

The partition key is used by Kinesis Data Streams as input to a hash function that maps the partition key and associated data to a specific shard. An MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards. As a result of this hashing mechanism, all data records with the same partition key map to the same shard within the stream. For more information, see Adding Data to a Stream in the Amazon Kinesis Data Streams Developer Guide.

Each record in the Records array may include an optional parameter, ExplicitHashKey, which overrides the partition key to shard mapping. This parameter allows a data producer to determine explicitly the shard where the record is stored. For more information, see Adding Multiple Records with PutRecords in the Amazon Kinesis Data Streams Developer Guide.

The PutRecords response includes an array of response Records. Each record in the response array directly correlates with a record in the request array using natural ordering, from the top to the bottom of the request and response. The response Records array always includes the same number of records as the request array.

The response Records array includes both successfully and unsuccessfully processed records. Kinesis Data Streams attempts to process all records in each PutRecords request. A single record failure does not stop the processing of subsequent records. As a result, PutRecords doesn't guarantee the ordering of records. If you need to read records in the same order they are written to the stream, use PutRecord instead of PutRecords, and write to the same shard.

A successfully processed record includes ShardId and SequenceNumber values. The ShardId parameter identifies the shard in the stream where the record is stored. The SequenceNumber parameter is an identifier assigned to the put record, unique to all records in the stream.

An unsuccessfully processed record includes ErrorCode and ErrorMessage values. ErrorCode reflects the type of error and can be one of the following values: ProvisionedThroughputExceededException or InternalFailure. ErrorMessage provides more detailed information about the ProvisionedThroughputExceededException exception including the account ID, stream name, and shard ID of the record that was throttled. For more information about partially successful responses, see Adding Multiple Records with PutRecords in the Amazon Kinesis Data Streams Developer Guide.

By default, data records are accessible for 24 hours from the time that they are added to a stream. You can use IncreaseStreamRetentionPeriod or DecreaseStreamRetentionPeriod to modify this retention period.

See also: AWS API Documentation

Request Syntax

client.put_records(
    Records=[
        {
            'Data': b'bytes',
            'ExplicitHashKey': 'string',
            'PartitionKey': 'string'
        },
    ],
    StreamName='string',
    StreamARN='string',
    StreamId='string',
    DryRun=True|False
)
type Records:

list

param Records:

[REQUIRED]

The records associated with the request.

  • (dict) --

    Represents the output for PutRecords.

    • Data (bytes) -- [REQUIRED]

      The data blob to put into the record, which is base64-encoded when the blob is serialized. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (10 MiB).

    • ExplicitHashKey (string) --

      The hash value used to determine explicitly the shard that the data record is assigned to by overriding the partition key hash.

    • PartitionKey (string) -- [REQUIRED]

      Determines which shard in the stream the data record is assigned to. Partition keys are Unicode strings with a maximum length limit of 256 characters for each key. Amazon Kinesis Data Streams uses the partition key as input to a hash function that maps the partition key and associated data to a specific shard. Specifically, an MD5 hash function is used to map partition keys to 128-bit integer values and to map associated data records to shards. As a result of this hashing mechanism, all data records with the same partition key map to the same shard within the stream.

type StreamName:

string

param StreamName:

The stream name associated with the request.

type StreamARN:

string

param StreamARN:

The ARN of the stream.

type StreamId:

string

param StreamId:

Not Implemented. Reserved for future use.

type DryRun:

boolean

param DryRun:

Checks if your request will succeed. DryRun is an optional parameter.

rtype:

dict

returns:

Response Syntax

{
    'FailedRecordCount': 123,
    'Records': [
        {
            'SequenceNumber': 'string',
            'ShardId': 'string',
            'ErrorCode': 'string',
            'ErrorMessage': 'string'
        },
    ],
    'EncryptionType': 'NONE'|'KMS'
}

Response Structure

  • (dict) --

    PutRecords results.

    • FailedRecordCount (integer) --

      The number of unsuccessfully processed records in a PutRecords request.

    • Records (list) --

      An array of successfully and unsuccessfully processed record results. A record that is successfully added to a stream includes SequenceNumber and ShardId in the result. A record that fails to be added to a stream includes ErrorCode and ErrorMessage in the result.

      • (dict) --

        Represents the result of an individual record from a PutRecords request. A record that is successfully added to a stream includes SequenceNumber and ShardId in the result. A record that fails to be added to the stream includes ErrorCode and ErrorMessage in the result.

        • SequenceNumber (string) --

          The sequence number for an individual record result.

        • ShardId (string) --

          The shard ID for an individual record result.

        • ErrorCode (string) --

          The error code for an individual record result. ErrorCodes can be either ProvisionedThroughputExceededException or InternalFailure.

        • ErrorMessage (string) --

          The error message for an individual record result. An ErrorCode value of ProvisionedThroughputExceededException has an error message that includes the account ID, stream name, and shard ID. An ErrorCode value of InternalFailure has the error message "Internal Service Failure".

    • EncryptionType (string) --

      The encryption type used on the records. This parameter can be one of the following values:

      • NONE: Do not encrypt the records.

      • KMS: Use server-side encryption on the records using a customer-managed Amazon Web Services KMS key.

SubscribeToShard (updated) Link ¶
Changes (request)
{'DryRun': 'boolean'}

This operation establishes an HTTP/2 connection between the consumer you specify in the ConsumerARN parameter and the shard you specify in the ShardId parameter. After the connection is successfully established, Kinesis Data Streams pushes records from the shard to the consumer over this connection. Before you call this operation, call RegisterStreamConsumer to register the consumer with Kinesis Data Streams.

When the SubscribeToShard call succeeds, your consumer starts receiving events of type SubscribeToShardEvent over the HTTP/2 connection for up to 5 minutes, after which time you need to call SubscribeToShard again to renew the subscription if you want to continue to receive records.

You can make one call to SubscribeToShard per second per registered consumer per shard. For example, if you have a 4000 shard stream and two registered stream consumers, you can make one SubscribeToShard request per second for each combination of shard and registered consumer, allowing you to subscribe both consumers to all 4000 shards in one second.

If you call SubscribeToShard again with the same ConsumerARN and ShardId within 5 seconds of a successful call, you'll get a ResourceInUseException. If you call SubscribeToShard 5 seconds or more after a successful call, the second call takes over the subscription and the previous connection expires or fails with a ResourceInUseException.

For an example of how to use this operation, see Enhanced Fan-Out Using the Kinesis Data Streams API.

See also: AWS API Documentation

Request Syntax

client.subscribe_to_shard(
    ConsumerARN='string',
    StreamId='string',
    ShardId='string',
    StartingPosition={
        'Type': 'AT_SEQUENCE_NUMBER'|'AFTER_SEQUENCE_NUMBER'|'TRIM_HORIZON'|'LATEST'|'AT_TIMESTAMP',
        'SequenceNumber': 'string',
        'Timestamp': datetime(2015, 1, 1)
    },
    DryRun=True|False
)
type ConsumerARN:

string

param ConsumerARN:

[REQUIRED]

For this parameter, use the value you obtained when you called RegisterStreamConsumer.

type StreamId:

string

param StreamId:

Not Implemented. Reserved for future use.

type ShardId:

string

param ShardId:

[REQUIRED]

The ID of the shard you want to subscribe to. To see a list of all the shards for a given stream, use ListShards.

type StartingPosition:

dict

param StartingPosition:

[REQUIRED]

The starting position in the data stream from which to start streaming.

  • Type (string) -- [REQUIRED]

    You can set the starting position to one of the following values:

    AT_SEQUENCE_NUMBER: Start streaming from the position denoted by the sequence number specified in the SequenceNumber field.

    AFTER_SEQUENCE_NUMBER: Start streaming right after the position denoted by the sequence number specified in the SequenceNumber field.

    AT_TIMESTAMP: Start streaming from the position denoted by the time stamp specified in the Timestamp field.

    TRIM_HORIZON: Start streaming at the last untrimmed record in the shard, which is the oldest data record in the shard.

    LATEST: Start streaming just after the most recent record in the shard, so that you always read the most recent data in the shard.

  • SequenceNumber (string) --

    The sequence number of the data record in the shard from which to start streaming. To specify a sequence number, set StartingPosition to AT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER.

  • Timestamp (datetime) --

    The time stamp of the data record from which to start reading. To specify a time stamp, set StartingPosition to Type AT_TIMESTAMP. A time stamp is the Unix epoch date with precision in milliseconds. For example, 2016-04-04T19:58:46.480-00:00 or 1459799926.480. If a record with this exact time stamp does not exist, records will be streamed from the next (later) record. If the time stamp is older than the current trim horizon, records will be streamed from the oldest untrimmed data record ( TRIM_HORIZON).

type DryRun:

boolean

param DryRun:

Checks if your request will succeed. DryRun is an optional parameter.

rtype:

dict

returns:

The response of this operation contains an :class:`.EventStream` member. When iterated the :class:`.EventStream` will yield events based on the structure below, where only one of the top level keys will be present for any given event.

Response Syntax

{
    'EventStream': EventStream({
        'SubscribeToShardEvent': {
            'Records': [
                {
                    'SequenceNumber': 'string',
                    'ApproximateArrivalTimestamp': datetime(2015, 1, 1),
                    'Data': b'bytes',
                    'PartitionKey': 'string',
                    'EncryptionType': 'NONE'|'KMS'
                },
            ],
            'ContinuationSequenceNumber': 'string',
            'MillisBehindLatest': 123,
            'ChildShards': [
                {
                    'ShardId': 'string',
                    'ParentShards': [
                        'string',
                    ],
                    'HashKeyRange': {
                        'StartingHashKey': 'string',
                        'EndingHashKey': 'string'
                    }
                },
            ]
        },
        'ResourceNotFoundException': {
            'message': 'string'
        },
        'ResourceInUseException': {
            'message': 'string'
        },
        'KMSDisabledException': {
            'message': 'string'
        },
        'KMSInvalidStateException': {
            'message': 'string'
        },
        'KMSAccessDeniedException': {
            'message': 'string'
        },
        'KMSNotFoundException': {
            'message': 'string'
        },
        'KMSOptInRequired': {
            'message': 'string'
        },
        'KMSThrottlingException': {
            'message': 'string'
        },
        'InternalFailureException': {
            'message': 'string'
        }
    })
}

Response Structure

  • (dict) --

    • EventStream (:class:`.EventStream`) --

      The event stream that your consumer can use to read records from the shard.

      • SubscribeToShardEvent (dict) --

        After you call SubscribeToShard, Kinesis Data Streams sends events of this type to your consumer. For an example of how to handle these events, see Enhanced Fan-Out Using the Kinesis Data Streams API.

        • Records (list) --

          • (dict) --

            The unit of data of the Kinesis data stream, which is composed of a sequence number, a partition key, and a data blob.

            • SequenceNumber (string) --

              The unique identifier of the record within its shard.

            • ApproximateArrivalTimestamp (datetime) --

              The approximate time that the record was inserted into the stream.

            • Data (bytes) --

              The data blob. The data in the blob is both opaque and immutable to Kinesis Data Streams, which does not inspect, interpret, or change the data in the blob in any way. When the data blob (the payload before base64-encoding) is added to the partition key size, the total size must not exceed the maximum record size (10 MiB).

            • PartitionKey (string) --

              Identifies which shard in the stream the data record is assigned to.

            • EncryptionType (string) --

              The encryption type used on the record. This parameter can be one of the following values:

              • NONE: Do not encrypt the records in the stream.

              • KMS: Use server-side encryption on the records in the stream using a customer-managed Amazon Web Services KMS key.

        • ContinuationSequenceNumber (string) --

          Use this as SequenceNumber in the next call to SubscribeToShard, with StartingPosition set to AT_SEQUENCE_NUMBER or AFTER_SEQUENCE_NUMBER. Use ContinuationSequenceNumber for checkpointing because it captures your shard progress even when no data is written to the shard.

        • MillisBehindLatest (integer) --

          The number of milliseconds the read records are from the tip of the stream, indicating how far behind current time the consumer is. A value of zero indicates that record processing is caught up, and there are no new records to process at this moment.

        • ChildShards (list) --

          The list of the child shards of the current shard, returned only at the end of the current shard.

          • (dict) --

            Output parameter of the GetRecords API. The existing child shard of the current shard.

            • ShardId (string) --

              The shard ID of the existing child shard of the current shard.

            • ParentShards (list) --

              The current shard that is the parent of the existing child shard.

              • (string) --

            • HashKeyRange (dict) --

              The range of possible hash key values for the shard, which is a set of ordered contiguous positive integers.

              • StartingHashKey (string) --

                The starting hash key of the hash key range.

              • EndingHashKey (string) --

                The ending hash key of the hash key range.

      • ResourceNotFoundException (dict) --

        The requested resource could not be found. The stream might not be specified correctly.

        • message (string) --

          A message that provides information about the error.

      • ResourceInUseException (dict) --

        The resource is not available for this operation. For successful operation, the resource must be in the ACTIVE state.

        • message (string) --

          A message that provides information about the error.

      • KMSDisabledException (dict) --

        The request was rejected because the specified customer master key (CMK) isn't enabled.

        • message (string) --

          A message that provides information about the error.

      • KMSInvalidStateException (dict) --

        The request was rejected because the state of the specified resource isn't valid for this request. For more information, see How Key State Affects Use of a Customer Master Key in the Amazon Web Services Key Management Service Developer Guide.

        • message (string) --

          A message that provides information about the error.

      • KMSAccessDeniedException (dict) --

        The ciphertext references a key that doesn't exist or that you don't have access to.

        • message (string) --

          A message that provides information about the error.

      • KMSNotFoundException (dict) --

        The request was rejected because the specified entity or resource can't be found.

        • message (string) --

          A message that provides information about the error.

      • KMSOptInRequired (dict) --

        The Amazon Web Services access key ID needs a subscription for the service.

        • message (string) --

          A message that provides information about the error.

      • KMSThrottlingException (dict) --

        The request was denied due to request throttling. For more information about throttling, see Limits in the Amazon Web Services Key Management Service Developer Guide.

        • message (string) --

          A message that provides information about the error.

      • InternalFailureException (dict) --

        The processing of the request failed because of an unknown error, exception, or failure.

        • message (string) --