UpdateStreamRecordDistributionStrategy
Updates the record distribution strategy for the specified Amazon Kinesis Data Streams on-demand data stream. The record distribution strategy determines how Amazon Kinesis Data Streams distributes records across the shards in a stream.
Note
You must specify the stream using the StreamARN parameter.
The record distribution strategy is a stream-level setting. You can switch between the following strategies at any time, and the change takes effect immediately without downtime, data loss, or disruption to producer or consumer applications:
-
AUTO– Amazon Kinesis Data Streams distributes records evenly across shards using service-managed algorithms, and ignores any partition key andExplicitHashKeythat a producer provides. Use this strategy for stateless workloads that do not require partition-key ordering. -
USER_PARTITION_KEY– Producers must provide a partition key, and Amazon Kinesis Data Streams uses the partition key to determine shard placement. Records that share a partition key are sent to the same shard. This is the default strategy.
This operation is only supported for data streams that use the on-demand capacity
mode. Provisioned capacity mode streams do not support the record distribution strategy
setting. Attempting to set AUTO on a provisioned stream results in an
InvalidArgumentException.
New records that arrive after the change are distributed according to the new strategy. Records already in the stream keep their original shard assignments and are not redistributed.
Request Syntax
{
"RecordDistributionStrategy": "string",
"StreamARN": "string",
"StreamId": "string"
}
Request Parameters
The request accepts the following data in JSON format.
- RecordDistributionStrategy
-
The record distribution strategy to apply to the stream. Specify one of the following values:
-
AUTO– Amazon Kinesis Data Streams distributes records evenly across shards and ignores any partition key andExplicitHashKeythat producers supply. -
USER_PARTITION_KEY– Producers must supply a partition key, which Amazon Kinesis Data Streams uses to determine shard placement. This is the default.
Type: String
Valid Values:
AUTO | USER_PARTITION_KEYRequired: Yes
-
- StreamARN
-
The Amazon Resource Name (ARN) of the stream to update.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 2048.
Pattern:
arn:aws.*:kinesis:.*:\d{12}:stream/\S+Required: Yes
- StreamId
-
Not Implemented. Reserved for future use.
Type: String
Length Constraints: Minimum length of 1. Maximum length of 24.
Pattern:
[a-z0-9]{20}-[a-z0-9]{3}Required: No
Response Elements
If the action is successful, the service sends back an HTTP 200 response with an empty HTTP body.
Errors
For information about the errors that are common to all actions, see Common Error Types.
- AccessDeniedException
-
Specifies that you do not have the permissions required to perform this operation.
HTTP Status Code: 400
- InvalidArgumentException
-
A specified parameter exceeds its restrictions, is not supported, or can't be used. For more information, see the returned message.
- message
-
A message that provides information about the error.
HTTP Status Code: 400
- LimitExceededException
-
The requested resource exceeds the maximum number allowed, or the number of concurrent stream requests exceeds the maximum number allowed.
- message
-
A message that provides information about the error.
HTTP Status Code: 400
- ResourceInUseException
-
The resource is not available for this operation. For successful operation, the resource must be in the
ACTIVEstate.- message
-
A message that provides information about the error.
HTTP Status Code: 400
- ResourceNotFoundException
-
The requested resource could not be found. The stream might not be specified correctly.
- message
-
A message that provides information about the error.
HTTP Status Code: 400
- ValidationException
-
Specifies that you tried to invoke this API for a data stream with the on-demand capacity mode. This API is only supported for data streams with the provisioned capacity mode.
HTTP Status Code: 400
Examples
To set the record distribution strategy to AUTO
The following example sets the record distribution strategy to
AUTO for the specified on-demand data stream. After this change,
Amazon Kinesis Data Streams distributes new records evenly across shards using
service-managed algorithms and ignores any partition key and
ExplicitHashKey that producers provide.
Sample Request
POST / HTTP/1.1
Host: kinesis.<region>.<domain>
Content-Length: <PayloadSizeBytes>
User-Agent: <UserAgentString>
Content-Type: application/x-amz-json-1.1
Authorization: <AuthParams>
Connection: Keep-Alive
X-Amz-Date: <Date>
X-Amz-Target: Kinesis_20131202.UpdateStreamRecordDistributionStrategy
{
"StreamARN": "arn:aws:kinesis:us-east-1:123456789012:stream/exampleStreamName",
"RecordDistributionStrategy": "AUTO"
}
Sample Response
HTTP/1.1 200 OK
x-amzn-RequestId: <RequestId>
Content-Type: application/x-amz-json-1.1
Content-Length: <PayloadSizeBytes>
Date: <Date>
See Also
For more information about using this API in one of the language-specific AWS SDKs, see the following: