@@ -311,7 +311,7 @@ export = {
311
311
DeletionPolicy : "Retain" ,
312
312
UpdateReplacePolicy : "Retain" ,
313
313
} ,
314
- MyKeyAlias1B45D9DA : {
314
+ MyKeyAliasaliasxoo9464EB1C : {
315
315
Type : "AWS::KMS::Alias" ,
316
316
Properties : {
317
317
AliasName : "alias/xoo" ,
@@ -329,6 +329,103 @@ export = {
329
329
test . done ( ) ;
330
330
} ,
331
331
332
+ 'can run multiple addAlias' ( test : Test ) {
333
+ const app = new App ( ) ;
334
+ const stack = new Stack ( app , 'Test' ) ;
335
+
336
+ const key = new Key ( stack , 'MyKey' , {
337
+ enableKeyRotation : true ,
338
+ enabled : false
339
+ } ) ;
340
+
341
+ const alias1 = key . addAlias ( 'alias/alias1' ) ;
342
+ const alias2 = key . addAlias ( 'alias/alias2' ) ;
343
+ test . ok ( alias1 . aliasName ) ;
344
+ test . ok ( alias2 . aliasName ) ;
345
+
346
+ expect ( stack ) . toMatch ( {
347
+ Resources : {
348
+ MyKey6AB29FA6 : {
349
+ Type : "AWS::KMS::Key" ,
350
+ Properties : {
351
+ EnableKeyRotation : true ,
352
+ Enabled : false ,
353
+ KeyPolicy : {
354
+ Statement : [
355
+ {
356
+ Action : [
357
+ "kms:Create*" ,
358
+ "kms:Describe*" ,
359
+ "kms:Enable*" ,
360
+ "kms:List*" ,
361
+ "kms:Put*" ,
362
+ "kms:Update*" ,
363
+ "kms:Revoke*" ,
364
+ "kms:Disable*" ,
365
+ "kms:Get*" ,
366
+ "kms:Delete*" ,
367
+ "kms:ScheduleKeyDeletion" ,
368
+ "kms:CancelKeyDeletion" ,
369
+ "kms:GenerateDataKey"
370
+ ] ,
371
+ Effect : "Allow" ,
372
+ Principal : {
373
+ AWS : {
374
+ "Fn::Join" : [
375
+ "" ,
376
+ [
377
+ "arn:" ,
378
+ {
379
+ Ref : "AWS::Partition"
380
+ } ,
381
+ ":iam::" ,
382
+ {
383
+ Ref : "AWS::AccountId"
384
+ } ,
385
+ ":root"
386
+ ]
387
+ ]
388
+ }
389
+ } ,
390
+ Resource : "*"
391
+ }
392
+ ] ,
393
+ Version : "2012-10-17"
394
+ }
395
+ } ,
396
+ DeletionPolicy : "Retain" ,
397
+ UpdateReplacePolicy : "Retain" ,
398
+ } ,
399
+ MyKeyAliasaliasalias1668D31D7 : {
400
+ Type : "AWS::KMS::Alias" ,
401
+ Properties : {
402
+ AliasName : "alias/alias1" ,
403
+ TargetKeyId : {
404
+ "Fn::GetAtt" : [
405
+ "MyKey6AB29FA6" ,
406
+ "Arn"
407
+ ]
408
+ }
409
+ }
410
+ } ,
411
+ MyKeyAliasaliasalias2EC56BD3E : {
412
+ Type : "AWS::KMS::Alias" ,
413
+ Properties : {
414
+ AliasName : "alias/alias2" ,
415
+ TargetKeyId : {
416
+ "Fn::GetAtt" : [
417
+ "MyKey6AB29FA6" ,
418
+ "Arn"
419
+ ]
420
+ }
421
+ }
422
+ }
423
+ }
424
+ } ) ;
425
+
426
+ test . done ( ) ;
427
+ } ,
428
+
332
429
'grant decrypt on a key' ( test : Test ) {
333
430
// GIVEN
334
431
const stack = new Stack ( ) ;
@@ -387,7 +484,7 @@ export = {
387
484
388
485
expect ( stack2 ) . toMatch ( {
389
486
Resources : {
390
- MyKeyImportedAliasB1C5269F : {
487
+ MyKeyImportedAliasaliashelloD41FEB6C : {
391
488
Type : "AWS::KMS::Alias" ,
392
489
Properties : {
393
490
AliasName : "alias/hello" ,
0 commit comments