Skip to content

Commit 8ac6f9e

Browse files
committed
chore: wip
1 parent 300bc85 commit 8ac6f9e

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

.stacks/core/cloud/src/cloud.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
aws_ec2 as ec2,
2222
aws_efs as efs,
2323
aws_iam as iam,
24+
aws_kms as kms,
2425
aws_lambda as lambda,
2526
aws_cloudfront_origins as origins,
2627
aws_route53 as route53,
@@ -58,6 +59,7 @@ export class StacksCloud extends Stack {
5859
redirectZones: route53.IHostedZone[] = []
5960
ec2Instance?: ec2.Instance
6061
vpc!: ec2.Vpc
62+
encryptionKey!: kms.Key
6163

6264
storage!: {
6365
publicBucket: s3.Bucket | s3.IBucket
@@ -102,6 +104,10 @@ export class StacksCloud extends Stack {
102104
this.privateSource = '../../../storage/private'
103105
this.apiVanityUrl = ''
104106

107+
this.encryptionKey = new kms.Key(this, 'StacksEncryptionKey', {
108+
description: 'KMS key for Stacks Cloud',
109+
enableKeyRotation: true,
110+
})
105111
this.manageUsers()
106112
this.manageZone()
107113
this.manageEmailServer()
@@ -369,7 +375,7 @@ export class StacksCloud extends Stack {
369375
// Daily 35 day retention
370376
const vault = new backup.BackupVault(this, 'BackupVault', {
371377
backupVaultName: `${this.appName}-${appEnv}-daily-backup-vault-${timestamp}`,
372-
encryptionKey: this.storage?.emailBucket?.encryptionKey,
378+
encryptionKey: this.encryptionKey,
373379
})
374380
const plan = backup.BackupPlan.daily35DayRetention(this, 'BackupPlan', vault)
375381

@@ -766,7 +772,7 @@ export class StacksCloud extends Stack {
766772
{
767773
s3Action: {
768774
bucketName: this.storage.emailBucket.bucketName,
769-
kmsKeyArn: this.storage.emailBucket.encryptionKey?.keyArn,
775+
kmsKeyArn: this.encryptionKey.keyArn,
770776
objectKeyPrefix: 'tmp/email_in',
771777
},
772778
},
@@ -1199,7 +1205,7 @@ export class StacksCloud extends Stack {
11991205
versioned: true,
12001206
removalPolicy: RemovalPolicy.DESTROY,
12011207
autoDeleteObjects: true,
1202-
encryption: s3.BucketEncryption.KMS_MANAGED,
1208+
encryptionKey: this.encryptionKey,
12031209
enforceSSL: true,
12041210
publicReadAccess: false,
12051211
blockPublicAccess: {
@@ -1227,7 +1233,7 @@ export class StacksCloud extends Stack {
12271233
versioned: true,
12281234
removalPolicy: RemovalPolicy.DESTROY,
12291235
autoDeleteObjects: true,
1230-
encryption: s3.BucketEncryption.KMS_MANAGED,
1236+
encryptionKey: this.encryptionKey,
12311237
lifecycleRules: [
12321238
{
12331239
id: '24h',
@@ -1239,7 +1245,7 @@ export class StacksCloud extends Stack {
12391245
{
12401246
id: 'Intelligent transition for Inbox',
12411247
enabled: true,
1242-
prefix: 'Inbox/',
1248+
prefix: 'inbox/',
12431249
transitions: [
12441250
{
12451251
storageClass: s3.StorageClass.INTELLIGENT_TIERING,
@@ -1250,7 +1256,7 @@ export class StacksCloud extends Stack {
12501256
{
12511257
id: 'Intelligent transition for Sent',
12521258
enabled: true,
1253-
prefix: 'Sent/',
1259+
prefix: 'sent/',
12541260
transitions: [
12551261
{
12561262
storageClass: s3.StorageClass.INTELLIGENT_TIERING,

0 commit comments

Comments
 (0)