@@ -22,6 +22,9 @@ describe('Kinesis data streams', () => {
22
22
Type : 'AWS::Kinesis::Stream' ,
23
23
Properties : {
24
24
ShardCount : 1 ,
25
+ StreamModeDetails : {
26
+ StreamMode : StreamMode . PROVISIONED ,
27
+ } ,
25
28
RetentionPeriodHours : 24 ,
26
29
StreamEncryption : {
27
30
'Fn::If' : [
@@ -75,6 +78,9 @@ describe('Kinesis data streams', () => {
75
78
Type : 'AWS::Kinesis::Stream' ,
76
79
Properties : {
77
80
ShardCount : 1 ,
81
+ StreamModeDetails : {
82
+ StreamMode : StreamMode . PROVISIONED ,
83
+ } ,
78
84
RetentionPeriodHours : 24 ,
79
85
StreamEncryption : {
80
86
'Fn::If' : [
@@ -94,6 +100,9 @@ describe('Kinesis data streams', () => {
94
100
Type : 'AWS::Kinesis::Stream' ,
95
101
Properties : {
96
102
ShardCount : 1 ,
103
+ StreamModeDetails : {
104
+ StreamMode : StreamMode . PROVISIONED ,
105
+ } ,
97
106
RetentionPeriodHours : 24 ,
98
107
StreamEncryption : {
99
108
'Fn::If' : [
@@ -158,6 +167,9 @@ describe('Kinesis data streams', () => {
158
167
Type : 'AWS::Kinesis::Stream' ,
159
168
Properties : {
160
169
ShardCount : 2 ,
170
+ StreamModeDetails : {
171
+ StreamMode : StreamMode . PROVISIONED ,
172
+ } ,
161
173
RetentionPeriodHours : 24 ,
162
174
StreamEncryption : {
163
175
'Fn::If' : [
@@ -212,6 +224,9 @@ describe('Kinesis data streams', () => {
212
224
Type : 'AWS::Kinesis::Stream' ,
213
225
Properties : {
214
226
ShardCount : 1 ,
227
+ StreamModeDetails : {
228
+ StreamMode : StreamMode . PROVISIONED ,
229
+ } ,
215
230
RetentionPeriodHours : 168 ,
216
231
StreamEncryption : {
217
232
'Fn::If' : [
@@ -283,6 +298,9 @@ describe('Kinesis data streams', () => {
283
298
Type : 'AWS::Kinesis::Stream' ,
284
299
Properties : {
285
300
ShardCount : 1 ,
301
+ StreamModeDetails : {
302
+ StreamMode : StreamMode . PROVISIONED ,
303
+ } ,
286
304
RetentionPeriodHours : 24 ,
287
305
StreamEncryption : {
288
306
EncryptionType : 'KMS' ,
@@ -319,6 +337,9 @@ describe('Kinesis data streams', () => {
319
337
// THEN
320
338
expect ( stack ) . toHaveResource ( 'AWS::Kinesis::Stream' , {
321
339
ShardCount : 1 ,
340
+ StreamModeDetails : {
341
+ StreamMode : StreamMode . PROVISIONED ,
342
+ } ,
322
343
RetentionPeriodHours : 24 ,
323
344
StreamEncryption : {
324
345
EncryptionType : 'KMS' ,
@@ -365,31 +386,90 @@ describe('Kinesis data streams', () => {
365
386
} ) ;
366
387
367
388
expect ( stack ) . toHaveResource ( 'AWS::Kinesis::Stream' , {
368
- RetentionPeriodHours : 24 ,
369
389
ShardCount : 1 ,
390
+ StreamModeDetails : {
391
+ StreamMode : StreamMode . PROVISIONED ,
392
+ } ,
393
+ RetentionPeriodHours : 24 ,
370
394
StreamEncryption : {
371
395
EncryptionType : 'KMS' ,
372
396
KeyId : stack . resolve ( explicitKey . keyArn ) ,
373
397
} ,
374
398
} ) ;
375
399
} ) ,
376
400
377
- test . each ( [ StreamMode . ON_DEMAND , StreamMode . PROVISIONED ] ) ( 'uses explicit capacity mode %s ' , ( mode : StreamMode ) => {
401
+ test ( 'uses explicit provisioned streamMode ' , ( ) => {
378
402
const stack = new Stack ( ) ;
379
403
380
404
new Stream ( stack , 'MyStream' , {
381
- streamMode : mode ,
405
+ streamMode : StreamMode . PROVISIONED ,
382
406
} ) ;
383
407
384
408
expect ( stack ) . toMatchTemplate ( {
385
409
Resources : {
386
410
MyStream5C050E93 : {
387
411
Type : 'AWS::Kinesis::Stream' ,
388
412
Properties : {
413
+ RetentionPeriodHours : 24 ,
389
414
ShardCount : 1 ,
415
+ StreamModeDetails : {
416
+ StreamMode : StreamMode . PROVISIONED ,
417
+ } ,
418
+ StreamEncryption : {
419
+ 'Fn::If' : [
420
+ 'AwsCdkKinesisEncryptedStreamsUnsupportedRegions' ,
421
+ {
422
+ Ref : 'AWS::NoValue' ,
423
+ } ,
424
+ {
425
+ EncryptionType : 'KMS' ,
426
+ KeyId : 'alias/aws/kinesis' ,
427
+ } ,
428
+ ] ,
429
+ } ,
430
+ } ,
431
+ } ,
432
+ } ,
433
+ Conditions : {
434
+ AwsCdkKinesisEncryptedStreamsUnsupportedRegions : {
435
+ 'Fn::Or' : [
436
+ {
437
+ 'Fn::Equals' : [
438
+ {
439
+ Ref : 'AWS::Region' ,
440
+ } ,
441
+ 'cn-north-1' ,
442
+ ] ,
443
+ } ,
444
+ {
445
+ 'Fn::Equals' : [
446
+ {
447
+ Ref : 'AWS::Region' ,
448
+ } ,
449
+ 'cn-northwest-1' ,
450
+ ] ,
451
+ } ,
452
+ ] ,
453
+ } ,
454
+ } ,
455
+ } ) ;
456
+ } ) ;
457
+
458
+ test ( 'uses explicit on-demand streamMode' , ( ) => {
459
+ const stack = new Stack ( ) ;
460
+
461
+ new Stream ( stack , 'MyStream' , {
462
+ streamMode : StreamMode . ON_DEMAND ,
463
+ } ) ;
464
+
465
+ expect ( stack ) . toMatchTemplate ( {
466
+ Resources : {
467
+ MyStream5C050E93 : {
468
+ Type : 'AWS::Kinesis::Stream' ,
469
+ Properties : {
390
470
RetentionPeriodHours : 24 ,
391
471
StreamModeDetails : {
392
- StreamMode : StreamMode [ mode ] ,
472
+ StreamMode : StreamMode . ON_DEMAND ,
393
473
} ,
394
474
StreamEncryption : {
395
475
'Fn::If' : [
@@ -431,6 +511,17 @@ describe('Kinesis data streams', () => {
431
511
} ) ;
432
512
} ) ;
433
513
514
+ test ( 'throws when using shardCount with on-demand streamMode' , ( ) => {
515
+ const stack = new Stack ( ) ;
516
+
517
+ expect ( ( ) => {
518
+ new Stream ( stack , 'MyStream' , {
519
+ shardCount : 2 ,
520
+ streamMode : StreamMode . ON_DEMAND ,
521
+ } ) ;
522
+ } ) . toThrow ( `streamMode must be set to ${ StreamMode . PROVISIONED } (default) when specifying shardCount` ) ;
523
+ } ) ;
524
+
434
525
test ( 'grantRead creates and attaches a policy with read only access to the principal' , ( ) => {
435
526
const stack = new Stack ( ) ;
436
527
const stream = new Stream ( stack , 'MyStream' , {
@@ -536,6 +627,9 @@ describe('Kinesis data streams', () => {
536
627
Type : 'AWS::Kinesis::Stream' ,
537
628
Properties : {
538
629
ShardCount : 1 ,
630
+ StreamModeDetails : {
631
+ StreamMode : StreamMode . PROVISIONED ,
632
+ } ,
539
633
RetentionPeriodHours : 24 ,
540
634
StreamEncryption : {
541
635
EncryptionType : 'KMS' ,
@@ -695,6 +789,9 @@ describe('Kinesis data streams', () => {
695
789
Type : 'AWS::Kinesis::Stream' ,
696
790
Properties : {
697
791
ShardCount : 1 ,
792
+ StreamModeDetails : {
793
+ StreamMode : StreamMode . PROVISIONED ,
794
+ } ,
698
795
RetentionPeriodHours : 24 ,
699
796
StreamEncryption : {
700
797
EncryptionType : 'KMS' ,
@@ -845,8 +942,11 @@ describe('Kinesis data streams', () => {
845
942
MyStream5C050E93 : {
846
943
Type : 'AWS::Kinesis::Stream' ,
847
944
Properties : {
848
- RetentionPeriodHours : 24 ,
849
945
ShardCount : 1 ,
946
+ StreamModeDetails : {
947
+ StreamMode : StreamMode . PROVISIONED ,
948
+ } ,
949
+ RetentionPeriodHours : 24 ,
850
950
StreamEncryption : {
851
951
EncryptionType : 'KMS' ,
852
952
KeyId : {
@@ -915,6 +1015,9 @@ describe('Kinesis data streams', () => {
915
1015
Type : 'AWS::Kinesis::Stream' ,
916
1016
Properties : {
917
1017
ShardCount : 1 ,
1018
+ StreamModeDetails : {
1019
+ StreamMode : StreamMode . PROVISIONED ,
1020
+ } ,
918
1021
RetentionPeriodHours : 24 ,
919
1022
StreamEncryption : {
920
1023
'Fn::If' : [
@@ -1003,6 +1106,9 @@ describe('Kinesis data streams', () => {
1003
1106
Type : 'AWS::Kinesis::Stream' ,
1004
1107
Properties : {
1005
1108
ShardCount : 1 ,
1109
+ StreamModeDetails : {
1110
+ StreamMode : StreamMode . PROVISIONED ,
1111
+ } ,
1006
1112
RetentionPeriodHours : 24 ,
1007
1113
StreamEncryption : {
1008
1114
'Fn::If' : [
@@ -1083,6 +1189,9 @@ describe('Kinesis data streams', () => {
1083
1189
Type : 'AWS::Kinesis::Stream' ,
1084
1190
Properties : {
1085
1191
ShardCount : 1 ,
1192
+ StreamModeDetails : {
1193
+ StreamMode : StreamMode . PROVISIONED ,
1194
+ } ,
1086
1195
RetentionPeriodHours : 24 ,
1087
1196
StreamEncryption : {
1088
1197
'Fn::If' : [
@@ -1173,6 +1282,9 @@ describe('Kinesis data streams', () => {
1173
1282
Type : 'AWS::Kinesis::Stream' ,
1174
1283
Properties : {
1175
1284
ShardCount : 1 ,
1285
+ StreamModeDetails : {
1286
+ StreamMode : StreamMode . PROVISIONED ,
1287
+ } ,
1176
1288
RetentionPeriodHours : 24 ,
1177
1289
StreamEncryption : {
1178
1290
'Fn::If' : [
@@ -1255,6 +1367,9 @@ describe('Kinesis data streams', () => {
1255
1367
Type : 'AWS::Kinesis::Stream' ,
1256
1368
Properties : {
1257
1369
ShardCount : 1 ,
1370
+ StreamModeDetails : {
1371
+ StreamMode : StreamMode . PROVISIONED ,
1372
+ } ,
1258
1373
RetentionPeriodHours : 24 ,
1259
1374
StreamEncryption : {
1260
1375
'Fn::If' : [
@@ -1372,6 +1487,9 @@ describe('Kinesis data streams', () => {
1372
1487
Type : 'AWS::Kinesis::Stream' ,
1373
1488
Properties : {
1374
1489
ShardCount : 1 ,
1490
+ StreamModeDetails : {
1491
+ StreamMode : StreamMode . PROVISIONED ,
1492
+ } ,
1375
1493
RetentionPeriodHours : {
1376
1494
Ref : 'myretentionperiod' ,
1377
1495
} ,
0 commit comments