Skip to content

Commit 50c2036

Browse files
committed
chore: wip
chore: wip
1 parent 32d7d38 commit 50c2036

File tree

2 files changed

+27
-29
lines changed

2 files changed

+27
-29
lines changed

.stacks/core/buddy/src/commands/cloud.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ export function cloud(buddy: CLI) {
130130
}
131131

132132
log.info('')
133-
log.info('ℹ️ Removing your cloud resources will take a while to complete. Please be patient.')
133+
log.info(`ℹ️ ${italic('Removing your cloud resources will take a while to complete. Please be patient.')}`)
134+
log.info(` ${italic('If you want to retain your buckets data, please back them up before.')}`)
134135
log.info('')
135136

136137
// sleep for 2 seconds to get the user to read the message

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

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
/* eslint-disable no-new */
22
import type { Construct } from 'constructs'
3-
import type {
4-
CfnResource,
5-
StackProps,
6-
} from 'aws-cdk-lib'
3+
import type { CfnResource, StackProps } from 'aws-cdk-lib'
74
import {
85
Duration,
96
Fn,
@@ -38,7 +35,7 @@ import type { EnvKey } from '~/storage/framework/stacks/env'
3835

3936
const appEnv = config.app.env === 'local' ? 'dev' : config.app.env
4037
const timestamp = new Date().getTime()
41-
const s3Sdk = new S3()
38+
// const s3Sdk = new S3()
4239

4340
function isProductionEnv(env: string) {
4441
return env === 'production' || env === 'prod'
@@ -80,7 +77,7 @@ export class StacksCloud extends Stack {
8077
super(scope, id, props)
8178
}
8279

83-
async init() {
80+
init() {
8481
// this is a noop function that is used to ensure the constructor is called
8582
// @ts-expect-error – we know this was properly set when needed
8683
this.storage = {}
@@ -105,9 +102,9 @@ export class StacksCloud extends Stack {
105102

106103
this.manageUsers()
107104
this.manageZone()
108-
await this.manageEmailServer()
105+
this.manageEmailServer()
109106
this.manageCertificate()
110-
await this.manageStorage()
107+
this.manageStorage()
111108
this.manageFirewall()
112109
this.manageFileSystem()
113110

@@ -319,12 +316,12 @@ export class StacksCloud extends Stack {
319316
})
320317
}
321318

322-
async manageStorage() {
319+
manageStorage() {
323320
// the bucketName cannot contain the domainName because when it is changed,
324321
// this resource needs to stay around/is retained. Hence, the domainName
325322
// does not make much sense using as a (linking) identifier
326323

327-
const publicBucket = await this.getOrCreateBucket()
324+
const publicBucket = this.createBucket()
328325
// for each redirect, create a bucket & redirect it to the APP_URL
329326
config.dns.redirects?.forEach((redirect) => {
330327
// TODO: use string-ts function here instead
@@ -345,13 +342,13 @@ export class StacksCloud extends Stack {
345342
})
346343
})
347344

348-
const privateBucket = await this.getOrCreateBucket('private')
345+
const privateBucket = this.createBucket('private')
349346

350347
let logBucket: s3.Bucket | undefined
351348
if (config.cloud.cdn?.enableLogging) {
352349
logBucket = new s3.Bucket(this, 'LogBucket', {
353350
bucketName: `${this.appName}-logs-${appEnv}-${timestamp}`,
354-
removalPolicy: RemovalPolicy.RETAIN,
351+
removalPolicy: RemovalPolicy.DESTROY,
355352
objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_PREFERRED,
356353
})
357354
}
@@ -522,8 +519,8 @@ export class StacksCloud extends Stack {
522519
return { cdn, originAccessIdentity, cdnCachePolicy }
523520
}
524521

525-
async manageEmailServer() {
526-
this.storage.emailBucket = await this.getOrCreateBucket('email')
522+
manageEmailServer() {
523+
this.storage.emailBucket = this.createBucket('email')
527524

528525
const sesPrincipal = new iam.ServicePrincipal('ses.amazonaws.com')
529526
const bucketPolicyStatement = new iam.PolicyStatement({
@@ -905,34 +902,34 @@ export class StacksCloud extends Stack {
905902
}
906903
}
907904

908-
async getOrCreateBucket(type?: 'public' | 'private' | 'email'): Promise<s3.Bucket | s3.IBucket> {
909-
let bucketPrefix, existingBucketName
905+
createBucket(type?: 'public' | 'private' | 'email'): s3.Bucket {
906+
let bucketPrefix
910907

911908
if (type === 'private') {
912909
bucketPrefix = `${this.appName}-private-${appEnv}-`
913-
existingBucketName = await getBucketWithPrefix(bucketPrefix)
910+
// existingBucketName = await getBucketWithPrefix(bucketPrefix)
914911

915-
if (existingBucketName)
916-
return s3.Bucket.fromBucketArn(this, 'PrivateBucket', `arn:aws:s3:::${existingBucketName}`)
912+
// if (existingBucketName)
913+
// return s3.Bucket.fromBucketArn(this, 'PrivateBucket', `arn:aws:s3:::${existingBucketName}`)
917914

918915
return new s3.Bucket(this, 'PrivateBucket', {
919916
bucketName: `${bucketPrefix}${timestamp}`,
920917
versioned: true,
921-
removalPolicy: RemovalPolicy.RETAIN,
918+
removalPolicy: RemovalPolicy.DESTROY,
922919
})
923920
}
924921

925922
if (type === 'email') {
926923
bucketPrefix = `${this.appName}-email-${appEnv}-`
927-
existingBucketName = await getBucketWithPrefix(bucketPrefix)
924+
// existingBucketName = await getBucketWithPrefix(bucketPrefix)
928925

929-
if (existingBucketName)
930-
return s3.Bucket.fromBucketArn(this, 'EmailServerBucket', `arn:aws:s3:::${existingBucketName}`)
926+
// if (existingBucketName)
927+
// return s3.Bucket.fromBucketArn(this, 'EmailServerBucket', `arn:aws:s3:::${existingBucketName}`)
931928

932929
return new s3.Bucket(this, 'EmailServerBucket', {
933930
bucketName: `${this.appName}-email-${appEnv}-${timestamp}`,
934931
versioned: true,
935-
removalPolicy: RemovalPolicy.RETAIN,
932+
removalPolicy: RemovalPolicy.DESTROY,
936933
lifecycleRules: [
937934
{
938935
id: '24h',
@@ -946,15 +943,15 @@ export class StacksCloud extends Stack {
946943
}
947944

948945
bucketPrefix = `${this.appName}-${appEnv}-`
949-
existingBucketName = await getBucketWithPrefix(bucketPrefix)
946+
// existingBucketName = await getBucketWithPrefix(bucketPrefix)
950947

951-
if (existingBucketName)
952-
return s3.Bucket.fromBucketArn(this, 'PublicBucket', `arn:aws:s3:::${existingBucketName}`)
948+
// if (existingBucketName)
949+
// return s3.Bucket.fromBucketArn(this, 'PublicBucket', `arn:aws:s3:::${existingBucketName}`)
953950

954951
return new s3.Bucket(this, 'PublicBucket', {
955952
bucketName: `${bucketPrefix}${timestamp}`,
956953
versioned: true,
957-
removalPolicy: RemovalPolicy.RETAIN,
954+
removalPolicy: RemovalPolicy.DESTROY,
958955
})
959956
}
960957

0 commit comments

Comments
 (0)