66 BlockPublicAccess ,
77 ObjectOwnership
88} from "aws-cdk-lib/aws-s3"
9- import { Key } from "aws-cdk-lib/aws-kms"
9+ import { Key , Alias } from "aws-cdk-lib/aws-kms"
1010
1111export interface S3BucketProps {
1212 readonly bucketName : string
@@ -16,13 +16,21 @@ export interface S3BucketProps {
1616export class S3Bucket extends Construct {
1717 public readonly bucket : Bucket
1818 public readonly kmsKey : Key
19+ public readonly kmsAlias : Alias
1920
2021 constructor ( scope : Construct , id : string , props : S3BucketProps ) {
2122 super ( scope , id )
2223
2324 this . kmsKey = new Key ( this , "BucketKey" , {
2425 enableKeyRotation : true ,
25- description : `KMS key for ${ props . bucketName } S3 bucket encryption`
26+ description : `KMS key for ${ props . bucketName } S3 bucket encryption` ,
27+ removalPolicy : RemovalPolicy . DESTROY
28+ } )
29+
30+ this . kmsAlias = new Alias ( this , "BucketKeyAlias" , {
31+ aliasName : `alias/${ props . bucketName } -s3-key` ,
32+ targetKey : this . kmsKey ,
33+ removalPolicy : RemovalPolicy . DESTROY
2634 } )
2735
2836 this . bucket = new Bucket ( this , props . bucketName , {
0 commit comments