1
1
import { InputTransformation , Pipe } from '@aws-cdk/aws-pipes-alpha' ;
2
- import { App , Stack } from 'aws-cdk-lib' ;
2
+ import { App , Lazy , Stack } from 'aws-cdk-lib' ;
3
3
import { Template } from 'aws-cdk-lib/assertions' ;
4
4
import { Stream } from 'aws-cdk-lib/aws-kinesis' ;
5
5
import { TestSource } from './test-classes' ;
@@ -94,8 +94,8 @@ describe('Kinesis', () => {
94
94
} ) ;
95
95
} ) ;
96
96
97
- describe ( 'Kinesis source parameters validation' , ( ) => {
98
- test ( 'Detail type must be <= 256 characters' , ( ) => {
97
+ describe ( 'Kinesis target parameters validation' , ( ) => {
98
+ test ( 'Partition key must be <= 256 characters' , ( ) => {
99
99
// GIVEN
100
100
const app = new App ( ) ;
101
101
const stack = new Stack ( app , 'TestStack' ) ;
@@ -108,4 +108,39 @@ describe('Kinesis source parameters validation', () => {
108
108
} ) ;
109
109
} ) . toThrow ( 'Partition key must be less than or equal to 256 characters, received 257' ) ;
110
110
} ) ;
111
+
112
+ test ( 'Partition key can be given for a token' , ( ) => {
113
+ // ARRANGE
114
+ const app = new App ( ) ;
115
+ const stack = new Stack ( app , 'TestStack' ) ;
116
+ const stream = new Stream ( stack , 'MyStream' , { } ) ;
117
+ const partitionKey = Lazy . string ( { produce : ( ) => '20' } ) ;
118
+
119
+ const target = new KinesisTarget ( stream , {
120
+ partitionKey,
121
+ } ) ;
122
+
123
+ new Pipe ( stack , 'MyPipe' , {
124
+ source : new TestSource ( ) ,
125
+ target,
126
+ } ) ;
127
+
128
+ // ACT
129
+ const template = Template . fromStack ( stack ) ;
130
+
131
+ // ASSERT
132
+ template . hasResourceProperties ( 'AWS::Pipes::Pipe' , {
133
+ Target : {
134
+ 'Fn::GetAtt' : [
135
+ 'MyStream5C050E93' ,
136
+ 'Arn' ,
137
+ ] ,
138
+ } ,
139
+ TargetParameters : {
140
+ KinesisStreamParameters : {
141
+ PartitionKey : '20' ,
142
+ } ,
143
+ } ,
144
+ } ) ;
145
+ } ) ;
111
146
} ) ;
0 commit comments