1
1
import { PolicyDocument , PolicyStatement } from '@aws-cdk/aws-iam' ;
2
- import { Construct , DeletionPolicy , IConstruct , Output , resolve } from '@aws-cdk/cdk' ;
2
+ import { Construct , DeletionPolicy , IConstruct , Output , resolve , TagManager , Tags } from '@aws-cdk/cdk' ;
3
3
import { EncryptionKeyAlias } from './alias' ;
4
4
import { CfnKey } from './kms.generated' ;
5
5
@@ -106,6 +106,11 @@ export interface EncryptionKeyProps {
106
106
* administer the key will be created.
107
107
*/
108
108
policy ?: PolicyDocument ;
109
+
110
+ /**
111
+ * The AWS resource tags to associate with the KMS key.
112
+ */
113
+ tags ?: Tags ;
109
114
}
110
115
111
116
/**
@@ -134,6 +139,11 @@ export class EncryptionKey extends EncryptionKeyBase {
134
139
return new ImportedEncryptionKey ( scope , id , props ) ;
135
140
}
136
141
142
+ /**
143
+ * Manage tags for this construct and children
144
+ */
145
+ public readonly tags : TagManager ;
146
+
137
147
public readonly keyArn : string ;
138
148
protected readonly policy ?: PolicyDocument ;
139
149
@@ -147,11 +157,14 @@ export class EncryptionKey extends EncryptionKeyBase {
147
157
this . allowAccountToAdmin ( ) ;
148
158
}
149
159
160
+ this . tags = new TagManager ( this , { initialTags : props . tags } ) ;
161
+
150
162
const resource = new CfnKey ( this , 'Resource' , {
151
163
description : props . description ,
152
164
enableKeyRotation : props . enableKeyRotation ,
153
165
enabled : props . enabled ,
154
- keyPolicy : this . policy
166
+ keyPolicy : this . policy ,
167
+ tags : this . tags
155
168
} ) ;
156
169
157
170
this . keyArn = resource . keyArn ;
0 commit comments