@@ -10,6 +10,7 @@ import * as cxapi from '@aws-cdk/cx-api';
10
10
import {
11
11
AuroraEngineVersion , AuroraMysqlEngineVersion , AuroraPostgresEngineVersion , CfnDBCluster , Credentials , DatabaseCluster ,
12
12
DatabaseClusterEngine , DatabaseClusterFromSnapshot , ParameterGroup , PerformanceInsightRetention , SubnetGroup , DatabaseSecret ,
13
+ DatabaseInstanceEngine , SqlServerEngineVersion ,
13
14
} from '../lib' ;
14
15
15
16
describe ( 'cluster' , ( ) => {
@@ -322,6 +323,112 @@ describe('cluster', () => {
322
323
} ) ;
323
324
} ) ;
324
325
326
+ test ( 'cluster with inline parameter group' , ( ) => {
327
+ // GIVEN
328
+ const stack = testStack ( ) ;
329
+ const vpc = new ec2 . Vpc ( stack , 'VPC' ) ;
330
+
331
+ // WHEN
332
+ new DatabaseCluster ( stack , 'Database' , {
333
+ engine : DatabaseClusterEngine . AURORA ,
334
+ parameters : {
335
+ locks : '100' ,
336
+ } ,
337
+ instanceProps : {
338
+ vpc,
339
+ parameters : {
340
+ locks : '200' ,
341
+ } ,
342
+ } ,
343
+ } ) ;
344
+
345
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::RDS::DBCluster' , {
346
+ DBClusterParameterGroupName : {
347
+ Ref : 'DatabaseParameterGroup2A921026' ,
348
+ } ,
349
+ } ) ;
350
+
351
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::RDS::DBClusterParameterGroup' , {
352
+ Family : 'aurora5.6' ,
353
+ Parameters : {
354
+ locks : '100' ,
355
+ } ,
356
+ } ) ;
357
+
358
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::RDS::DBInstance' , {
359
+ DBParameterGroupName : {
360
+ Ref : 'DatabaseInstanceParameterGroup6968C5BF' ,
361
+ } ,
362
+ } ) ;
363
+
364
+ Template . fromStack ( stack ) . hasResourceProperties ( 'AWS::RDS::DBParameterGroup' , {
365
+ Family : 'aurora5.6' ,
366
+ Parameters : {
367
+ locks : '200' ,
368
+ } ,
369
+ } ) ;
370
+ } ) ;
371
+
372
+ test ( 'cluster with inline parameter group and parameterGroup arg fails' , ( ) => {
373
+ // GIVEN
374
+ const stack = testStack ( ) ;
375
+ const vpc = new ec2 . Vpc ( stack , 'VPC' ) ;
376
+ const parameterGroup = new ParameterGroup ( stack , 'ParameterGroup' , {
377
+ engine : DatabaseInstanceEngine . sqlServerEe ( {
378
+ version : SqlServerEngineVersion . VER_11 ,
379
+ } ) ,
380
+ parameters : {
381
+ locks : '50' ,
382
+ } ,
383
+ } ) ;
384
+
385
+ expect ( ( ) => {
386
+ new DatabaseCluster ( stack , 'Database' , {
387
+ engine : DatabaseClusterEngine . AURORA ,
388
+ parameters : {
389
+ locks : '100' ,
390
+ } ,
391
+ parameterGroup,
392
+ instanceProps : {
393
+ vpc,
394
+ parameters : {
395
+ locks : '200' ,
396
+ } ,
397
+ } ,
398
+ } ) ;
399
+ } ) . toThrow ( / Y o u c a n n o t s p e c i f y b o t h p a r a m e t e r G r o u p a n d p a r a m e t e r s / ) ;
400
+ } ) ;
401
+
402
+ test ( 'instance with inline parameter group and parameterGroup arg fails' , ( ) => {
403
+ // GIVEN
404
+ const stack = testStack ( ) ;
405
+ const vpc = new ec2 . Vpc ( stack , 'VPC' ) ;
406
+ const parameterGroup = new ParameterGroup ( stack , 'ParameterGroup' , {
407
+ engine : DatabaseInstanceEngine . sqlServerEe ( {
408
+ version : SqlServerEngineVersion . VER_11 ,
409
+ } ) ,
410
+ parameters : {
411
+ locks : '50' ,
412
+ } ,
413
+ } ) ;
414
+
415
+ expect ( ( ) => {
416
+ new DatabaseCluster ( stack , 'Database' , {
417
+ engine : DatabaseClusterEngine . AURORA ,
418
+ parameters : {
419
+ locks : '100' ,
420
+ } ,
421
+ instanceProps : {
422
+ vpc,
423
+ parameterGroup,
424
+ parameters : {
425
+ locks : '200' ,
426
+ } ,
427
+ } ,
428
+ } ) ;
429
+ } ) . toThrow ( / Y o u c a n n o t s p e c i f y b o t h p a r a m e t e r G r o u p a n d p a r a m e t e r s / ) ;
430
+ } ) ;
431
+
325
432
describe ( 'performance insights' , ( ) => {
326
433
test ( 'cluster with all performance insights properties' , ( ) => {
327
434
// GIVEN
0 commit comments