Skip to content

merge_shards

Operation

merge_shards

merge_shards(request: MergeShardsInput | MergeShardsInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[MergeShardsInputDict]) -> MergeShardsOutput

Merges two adjacent shards in a Kinesis data stream and combines them into a single shard to reduce the stream's capacity to ingest and transport data. This API is only supported for the data streams with the provisioned capacity mode. Two shards are considered adjacent if the union of the hash key ranges for the two shards form a contiguous set with no gaps. For example, if you have two shards, one with a hash key range of 276...381 and the other with a hash key range of 382...454, then you could merge these two shards into a single shard that would have a hash key range of 276...454. After the merge, the single child shard receives data for all hash key values covered by the two parent shards.

Note

When invoking this API, you must use either the StreamARN or the StreamName parameter, or both. It is recommended that you use the StreamARN input parameter when you invoke this API.

MergeShards is called when there is a need to reduce the overall capacity of a stream because of excess capacity that is not being used. You must specify the shard to be merged and the adjacent shard for a stream. For more information about merging shards, see Merge Two Shards in the Amazon Kinesis Data Streams Developer Guide.

If the stream is in the ACTIVE state, you can call MergeShards. If a stream is in the CREATING, UPDATING, or DELETING state, MergeShards returns a ResourceInUseException. If the specified stream does not exist, MergeShards returns a ResourceNotFoundException.

You can use DescribeStreamSummary to check the state of the stream, which is returned in StreamStatus.

MergeShards is an asynchronous operation. Upon receiving a MergeShards request, Amazon Kinesis Data Streams immediately returns a response and sets the StreamStatus to UPDATING. After the operation is completed, Kinesis Data Streams sets the StreamStatus to ACTIVE. Read and write operations continue to work while the stream is in the UPDATING state.

You use DescribeStreamSummary and the ListShards APIs to determine the shard IDs that are specified in the MergeShards request.

If you try to operate on too many streams in parallel using CreateStream, DeleteStream, MergeShards, or SplitShard, you receive a LimitExceededException.

MergeShards has a limit of five transactions per second per account.

Parameters:

Name Type Description Default
request MergeShardsInput | MergeShardsInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[MergeShardsInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
MergeShardsOutput

An instance of MergeShardsOutput.

merge_shards async

merge_shards(request: MergeShardsInput | MergeShardsInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[MergeShardsInputDict]) -> MergeShardsOutput

Merges two adjacent shards in a Kinesis data stream and combines them into a single shard to reduce the stream's capacity to ingest and transport data. This API is only supported for the data streams with the provisioned capacity mode. Two shards are considered adjacent if the union of the hash key ranges for the two shards form a contiguous set with no gaps. For example, if you have two shards, one with a hash key range of 276...381 and the other with a hash key range of 382...454, then you could merge these two shards into a single shard that would have a hash key range of 276...454. After the merge, the single child shard receives data for all hash key values covered by the two parent shards.

Note

When invoking this API, you must use either the StreamARN or the StreamName parameter, or both. It is recommended that you use the StreamARN input parameter when you invoke this API.

MergeShards is called when there is a need to reduce the overall capacity of a stream because of excess capacity that is not being used. You must specify the shard to be merged and the adjacent shard for a stream. For more information about merging shards, see Merge Two Shards in the Amazon Kinesis Data Streams Developer Guide.

If the stream is in the ACTIVE state, you can call MergeShards. If a stream is in the CREATING, UPDATING, or DELETING state, MergeShards returns a ResourceInUseException. If the specified stream does not exist, MergeShards returns a ResourceNotFoundException.

You can use DescribeStreamSummary to check the state of the stream, which is returned in StreamStatus.

MergeShards is an asynchronous operation. Upon receiving a MergeShards request, Amazon Kinesis Data Streams immediately returns a response and sets the StreamStatus to UPDATING. After the operation is completed, Kinesis Data Streams sets the StreamStatus to ACTIVE. Read and write operations continue to work while the stream is in the UPDATING state.

You use DescribeStreamSummary and the ListShards APIs to determine the shard IDs that are specified in the MergeShards request.

If you try to operate on too many streams in parallel using CreateStream, DeleteStream, MergeShards, or SplitShard, you receive a LimitExceededException.

MergeShards has a limit of five transactions per second per account.

Parameters:

Name Type Description Default
request MergeShardsInput | MergeShardsInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[MergeShardsInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
MergeShardsOutput

An instance of MergeShardsOutput.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

MergeShardsInputDict

Bases: TypedDict

Dictionary form of MergeShardsInput.

Attributes

adjacent_shard_to_merge instance-attribute
adjacent_shard_to_merge: Required[str]

The shard ID of the adjacent shard for the merge.

shard_to_merge instance-attribute
shard_to_merge: Required[str]

The shard ID of the shard to combine with the adjacent shard for the merge.

stream_arn instance-attribute
stream_arn: str | None

The ARN of the stream.

stream_id instance-attribute
stream_id: str | None

Not Implemented. Reserved for future use.

stream_name instance-attribute
stream_name: str | None

The name of the stream for the merge.

MergeShardsInput dataclass

Bases: _SerdeShape

Represents the input for MergeShards.

Attributes

adjacent_shard_to_merge class-attribute instance-attribute
adjacent_shard_to_merge: str | None = ...

The shard ID of the adjacent shard for the merge.

shard_to_merge class-attribute instance-attribute
shard_to_merge: str | None = ...

The shard ID of the shard to combine with the adjacent shard for the merge.

stream_arn class-attribute instance-attribute
stream_arn: str | None = ...

The ARN of the stream.

stream_id class-attribute instance-attribute
stream_id: str | None = ...

Not Implemented. Reserved for future use.

stream_name class-attribute instance-attribute
stream_name: str | None = ...

The name of the stream for the merge.

Output

MergeShardsOutput dataclass

Bases: _SerdeShape

Dataclass for MergeShardsOutput structure.

Attributes

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.