File tree Expand file tree Collapse file tree 1 file changed +11
-11
lines changed
src/lib/cdk-accelerator/src/core Expand file tree Collapse file tree 1 file changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ export class SecretsContainer extends Construct {
4949
5050 constructor ( scope : Construct , name : string ) {
5151 super ( scope , name ) ;
52-
52+ cdk . Aspects . of ( this ) . add ( { visit : ( ) => this . prep ( ) } ) ;
5353 this . keyAlias = createEncryptionKeyName ( `Secrets-Key` ) ;
5454 this . encryptionKey = new kms . Key ( this , `EncryptionKey` , {
5555 alias : `alias/${ this . keyAlias } ` ,
@@ -80,16 +80,6 @@ export class SecretsContainer extends Construct {
8080 } ,
8181 } ) ,
8282 ) ;
83-
84- if ( this . principals . length ) {
85- this . encryptionKey . addToResourcePolicy (
86- new iam . PolicyStatement ( {
87- actions : [ 'kms:Decrypt' ] ,
88- resources : [ '*' ] ,
89- principals : this . principals ,
90- } ) ,
91- ) ;
92- }
9383 }
9484
9585 /**
@@ -116,4 +106,14 @@ export class SecretsContainer extends Construct {
116106 get alias ( ) {
117107 return this . keyAlias ;
118108 }
109+
110+ protected prep ( ) : void {
111+ this . encryptionKey . addToResourcePolicy (
112+ new iam . PolicyStatement ( {
113+ actions : [ 'kms:Decrypt' ] ,
114+ resources : [ '*' ] ,
115+ principals : this . principals ,
116+ } ) ,
117+ ) ;
118+ }
119119}
You can’t perform that action at this time.
0 commit comments