Search code examples
amazon-kinesisaws-java-sdk

Is there a way to programmatically get the maximum authorized number of shards for an Amazon Kinesis stream?


By default a Kinesis stream is authorized to have at most 10 shards, but it is possible to increase this limit. Is it possible to retrieve the limit for a stream programmatically? I wasn't able to find a method to do it in the official AWS Java SDK.


Solution

  • No, there doesn't seem to be an API call to do that. In any case, you have to contact AWS support and be approved for a limit increase, which means that this value is not likely to change often.

    If you really need to access this limit number dynamically, you might consider storing it in a database somewhere. Or, you might listen for and react to the exception that would be produced when you try to scale greater than your allowed limit.

    Note that if you are wondering about this for scaling purposes: Only open shards count toward this limit - So you can scale from 5 to 10 shards, and during the scale, the original 5 would be closed to become parent shards, which would mean you have 15 shards on your account for the 24 hours until those parent shards expire. This works fine.