Skip to content

Commit e0f8e5f

Browse files
committed
Add feedback from @nmussy
1 parent c2fbb62 commit e0f8e5f

File tree

3 files changed

+8
-15
lines changed

3 files changed

+8
-15
lines changed

packages/@aws-cdk/aws-pipes-targets-alpha/lib/kinesis.ts

+6-13
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,12 @@ export interface KinesisTargetParameters {
1010
* The input transformation to apply to the message before sending it to the target.
1111
*
1212
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetparameters.html#cfn-pipes-pipe-pipetargetparameters-inputtemplate
13-
* @default none
13+
* @default - none
1414
*/
1515
readonly inputTransformation?: IInputTransformation;
1616

1717
/**
18-
* Determines which shard in the stream the data record is assigned to. Partition keys are
19-
* Unicode strings with a maximum length limit of 256 characters for each key. Amazon Kinesis
20-
* Data Streams uses the partition key as input to a hash function that maps the partition key
21-
* and associated data to a specific shard. Specifically, an MD5 hash function is used to map
22-
* partition keys to 128-bit integer values and to map associated data records to shards. As a
23-
* result of this hashing mechanism, all data records with the same partition key map to the
24-
* same shard within the stream.
25-
*
26-
* Minimum: 0
27-
* Maximum: 256
18+
* Determines which shard in the stream the data record is assigned to.
2819
*
2920
* @see https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-pipes-pipe-pipetargetkinesisstreamparameters.html#cfn-pipes-pipe-pipetargetkinesisstreamparameters-partitionkey
3021
*/
@@ -46,9 +37,11 @@ export class KinesisTarget implements ITarget {
4637

4738
validatePartitionKey(parameters.partitionKey);
4839
}
40+
4941
grantPush(grantee: IRole): void {
5042
this.stream.grantWrite(grantee);
5143
}
44+
5245
bind(pipe: IPipe): TargetConfig {
5346
if (!this.streamParameters) {
5447
return {
@@ -66,7 +59,7 @@ export class KinesisTarget implements ITarget {
6659
}
6760

6861
function validatePartitionKey(pk: string) {
69-
if (pk.length < 0 || pk.length > 256) {
70-
throw new Error(`Partition key must be between 0 and 256 characters, received ${pk.length}`);
62+
if (pk.length > 256) {
63+
throw new Error(`Partition key must be less than or equal to 256 characters, received ${pk.length}`);
7164
}
7265
}

packages/@aws-cdk/aws-pipes-targets-alpha/test/integ.kinesis.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,6 @@ test.assertions.awsApiCall('SQS', 'sendMessage', {
4444

4545
// It is nontrivial to read from a Kinesis data stream.
4646
// Manual verification was done to ensure the record made
47-
// it from the SQS to Kinesis via the pipe.
47+
// it from SQS to Kinesis via the pipe.
4848

4949
app.synth();

packages/@aws-cdk/aws-pipes-targets-alpha/test/kinesis.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,6 @@ describe('Kinesis source parameters validation', () => {
106106
new KinesisTarget(stream, {
107107
partitionKey: 'x'.repeat(257),
108108
});
109-
}).toThrow('Partition key must be between 0 and 256 characters, received 257');
109+
}).toThrow('Partition key must be less than or equal to 256 characters, received 257');
110110
});
111111
});

0 commit comments

Comments
 (0)