@@ -21,6 +21,7 @@ import {
21
21
aws_ec2 as ec2 ,
22
22
aws_efs as efs ,
23
23
aws_iam as iam ,
24
+ aws_kms as kms ,
24
25
aws_lambda as lambda ,
25
26
aws_cloudfront_origins as origins ,
26
27
aws_route53 as route53 ,
@@ -58,6 +59,7 @@ export class StacksCloud extends Stack {
58
59
redirectZones : route53 . IHostedZone [ ] = [ ]
59
60
ec2Instance ?: ec2 . Instance
60
61
vpc ! : ec2 . Vpc
62
+ encryptionKey ! : kms . Key
61
63
62
64
storage ! : {
63
65
publicBucket : s3 . Bucket | s3 . IBucket
@@ -102,6 +104,10 @@ export class StacksCloud extends Stack {
102
104
this . privateSource = '../../../storage/private'
103
105
this . apiVanityUrl = ''
104
106
107
+ this . encryptionKey = new kms . Key ( this , 'StacksEncryptionKey' , {
108
+ description : 'KMS key for Stacks Cloud' ,
109
+ enableKeyRotation : true ,
110
+ } )
105
111
this . manageUsers ( )
106
112
this . manageZone ( )
107
113
this . manageEmailServer ( )
@@ -369,7 +375,7 @@ export class StacksCloud extends Stack {
369
375
// Daily 35 day retention
370
376
const vault = new backup . BackupVault ( this , 'BackupVault' , {
371
377
backupVaultName : `${ this . appName } -${ appEnv } -daily-backup-vault-${ timestamp } ` ,
372
- encryptionKey : this . storage ?. emailBucket ?. encryptionKey ,
378
+ encryptionKey : this . encryptionKey ,
373
379
} )
374
380
const plan = backup . BackupPlan . daily35DayRetention ( this , 'BackupPlan' , vault )
375
381
@@ -766,7 +772,7 @@ export class StacksCloud extends Stack {
766
772
{
767
773
s3Action : {
768
774
bucketName : this . storage . emailBucket . bucketName ,
769
- kmsKeyArn : this . storage . emailBucket . encryptionKey ? .keyArn ,
775
+ kmsKeyArn : this . encryptionKey . keyArn ,
770
776
objectKeyPrefix : 'tmp/email_in' ,
771
777
} ,
772
778
} ,
@@ -1199,7 +1205,7 @@ export class StacksCloud extends Stack {
1199
1205
versioned : true ,
1200
1206
removalPolicy : RemovalPolicy . DESTROY ,
1201
1207
autoDeleteObjects : true ,
1202
- encryption : s3 . BucketEncryption . KMS_MANAGED ,
1208
+ encryptionKey : this . encryptionKey ,
1203
1209
enforceSSL : true ,
1204
1210
publicReadAccess : false ,
1205
1211
blockPublicAccess : {
@@ -1227,7 +1233,7 @@ export class StacksCloud extends Stack {
1227
1233
versioned : true ,
1228
1234
removalPolicy : RemovalPolicy . DESTROY ,
1229
1235
autoDeleteObjects : true ,
1230
- encryption : s3 . BucketEncryption . KMS_MANAGED ,
1236
+ encryptionKey : this . encryptionKey ,
1231
1237
lifecycleRules : [
1232
1238
{
1233
1239
id : '24h' ,
@@ -1239,7 +1245,7 @@ export class StacksCloud extends Stack {
1239
1245
{
1240
1246
id : 'Intelligent transition for Inbox' ,
1241
1247
enabled : true ,
1242
- prefix : 'Inbox /' ,
1248
+ prefix : 'inbox /' ,
1243
1249
transitions : [
1244
1250
{
1245
1251
storageClass : s3 . StorageClass . INTELLIGENT_TIERING ,
@@ -1250,7 +1256,7 @@ export class StacksCloud extends Stack {
1250
1256
{
1251
1257
id : 'Intelligent transition for Sent' ,
1252
1258
enabled : true ,
1253
- prefix : 'Sent /' ,
1259
+ prefix : 'sent /' ,
1254
1260
transitions : [
1255
1261
{
1256
1262
storageClass : s3 . StorageClass . INTELLIGENT_TIERING ,
0 commit comments