-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(aws-kinesis): remove default shard count when stream mode is on-demand and set default mode to provisioned #18221
Conversation
Co-authored-by: AWS CDK Team <aws-cdk@amazon.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Align the import prefix for this additional class. Otherwise copying the code will not compile. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Explicitly declaring ShardCount with a default value can cause errors when using the on-demand stream mode. Instead, we can rely on CloudFormation's implicit defaults. part of #18139
Title does not follow the guidelines of Conventional Commits. Please adjust title before merge. |
The changes so far should fix the basic problem and allow the stream mode to be used. I haven't figured out how to do validation yet so any help would be appreciated. |
It looks like the dynamodb module just adds various guard statements and to the L2 construct constructor to prevent misuse of conflicting configuration options. I'll do the same. |
* Document that streamMode and shardCount conflict * Add a guard to prevent specifying shard count when stream mode is on-demand * Restore default shard count of 1 when stream mode is provisioned * Establish default stream mode of provisioned These changes make the stream configuration explicit in the generated CloudFormation templates again, matching the design of DynamoDB. Fixes #18139
message for error when setting streamMode to on-demand and also specifying shardCount
Okay, I think I'm ready for the first round of reviews. |
shardCount: 2, | ||
streamMode: StreamMode.ON_DEMAND, | ||
}); | ||
}).toThrow('streamMode must be set to PROVISIONED (default) when specifying shardCount'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use streamMode must be set to ${StreamMode.PROVISIONED} (default) when specifying shardCount
to keep the value of the enum even if it is changed in the future.
@@ -4,6 +4,9 @@ | |||
"Type": "AWS::Kinesis::Stream", | |||
"Properties": { | |||
"ShardCount": 1, | |||
"StreamModeDetails": { | |||
"StreamMode": "PROVISIONED" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check for ${StreamMode.PROVISIONED} for the exact enum values and same for ON_DEMAND occurences
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made this change in the unit tests. It's not applicable to these JSON files.
@@ -752,9 +755,15 @@ export class Stream extends StreamBase { | |||
physicalName: props.streamName, | |||
}); | |||
|
|||
const shardCount = props.shardCount || 1; | |||
let shardCount = props.shardCount; | |||
let streamMode = props.streamMode ?? StreamMode.PROVISIONED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this commit, you are making two changes, ie. the fix and the default to PROVISIONED capacity. You can include that in the commit details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the description. Hopefully that's a bit clearer.
I'm back from today if there's any more feedback on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me, I wish I saw this before I submitted my own PR! Thank you for the contribution 🙂
Thank you also to @d4r3topk for the initial review!
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
AWS CodeBuild CI Report
Powered by github-codebuild-logs, available on the AWS Serverless Application Repository |
Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork). |
Since v1.139.0 the `StreamMode` of a Kinesis stream is `PROVISIONED` by default. The stream mode can be one of two options: - On-demand - data streams with an on-demand mode require no capacity planning and automatically scale to handle gigabytes of write and read throughput per minute. With the on-demand mode, Kinesis Data Streams automatically manages the shards in order to provide the necessary throughput. - Provisioned - for the data streams with a provisioned mode, you must specify the number of shards for the data stream. The total capacity of a data stream is the sum of the capacities of its shards. You can increase or decrease the number of shards in a data stream as needed. Provisioned matches our use of Kinesis today, so the default makes sense. See: - aws/aws-cdk#18221 - https://docs.aws.amazon.com/streams/latest/dev/how-do-i-size-a-stream.html
…emand and set default mode to provisioned (aws#18221) Change the default Kinesis Data Stream's stream mode to provisioned from undefined to make the active configuration more explicit in the resulting CloudFormation templates. Fix an issue whereby the shard count is always set when the stream mode is set to on-demand, which is invalid. Shard count still defaults to `1` in provisioned mode, but is left undefined in on-demand mode. Add validation for the above so that an error is thrown from CDK when specifying on-demand mode with a shard count. Fixes aws#18139 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Change the default Kinesis Data Stream's stream mode to provisioned from undefined to make the active configuration more explicit in the resulting CloudFormation templates.
Fix an issue whereby the shard count is always set when the stream mode is set to on-demand, which is invalid. Shard count still defaults to
1
in provisioned mode, but is left undefined in on-demand mode.Add validation for the above so that an error is thrown from CDK when specifying on-demand mode with a shard count.
Fixes #18139
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license