66 Billing ,
77 TableEncryptionV2
88} from "aws-cdk-lib/aws-dynamodb"
9- import { Key } from "aws-cdk-lib/aws-kms"
9+ import { Key , Alias } from "aws-cdk-lib/aws-kms"
1010
1111export interface DynamoDbTableProps {
1212 readonly tableName : string
@@ -20,13 +20,21 @@ export interface DynamoDbTableProps {
2020export class DynamoDbTable extends Construct {
2121 public readonly table : TableV2
2222 public readonly kmsKey : Key
23+ public readonly kmsAlias : Alias
2324
2425 constructor ( scope : Construct , id : string , props : DynamoDbTableProps ) {
2526 super ( scope , id )
2627
2728 this . kmsKey = new Key ( this , "TableKey" , {
2829 enableKeyRotation : true ,
29- description : `KMS key for ${ props . tableName } DynamoDB table encryption`
30+ description : `KMS key for ${ props . tableName } DynamoDB table encryption` ,
31+ removalPolicy : RemovalPolicy . DESTROY
32+ } )
33+
34+ this . kmsAlias = new Alias ( this , "TableKeyAlias" , {
35+ aliasName : `alias/${ props . tableName } -dynamodb-key` ,
36+ targetKey : this . kmsKey ,
37+ removalPolicy : RemovalPolicy . DESTROY
3038 } )
3139
3240 this . table = new TableV2 ( this , props . tableName , {
0 commit comments