Skip to content

Commit 9738d3e

Browse files
committed
chore: wip
1 parent 8ca39b5 commit 9738d3e

File tree

5 files changed

+24
-17
lines changed

5 files changed

+24
-17
lines changed

.stacks/core/actions/src/zip/api.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// zip the api for deployment
2-
import { zip } from '@stacksjs/storage'
2+
import { log } from '@stacksjs/logging'
33
import { path as p } from '@stacksjs/path'
4-
import { logger } from '@stacksjs/logging'
4+
import { zip } from '@stacksjs/storage'
55

6-
logger.log('zipping your API for Lambda usage...')
6+
log.info('zipping your API for Lambda usage...')
77

88
const from = [
99
'bootstrap',
@@ -18,5 +18,4 @@ await zip(from, to, {
1818
cwd: p.cloudPath('src/drivers/aws/runtime'),
1919
})
2020

21-
logger.log('✓ zipped your API')
22-
logger.log('')
21+
log.info('zipped your API')

.stacks/core/cloud/deploy.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import process from 'node:process'
2-
import * as cdk from 'aws-cdk-lib'
3-
import { env } from '@stacksjs/env'
41
import { config } from '@stacksjs/config'
2+
import { env } from '@stacksjs/env'
3+
import * as cdk from 'aws-cdk-lib'
4+
import process from 'node:process'
55
import { StacksCloud } from './src/cloud'
66

77
const app = new cdk.App()
88
const appEnv = config.app.env === 'local' ? 'dev' : config.app.env
9+
// stacks-cloud-${appEnv}`
910
const cloudName = `stacks-cloud-${appEnv}`
1011
const account = env.AWS_ACCOUNT_ID
1112
const region = env.AWS_DEFAULT_REGION
@@ -15,7 +16,8 @@ if (!account || !region) {
1516
process.exit(1)
1617
}
1718

18-
const cloud = new StacksCloud(app, cloudName, {
19+
const cloud = new StacksCloud(app, 'StacksCloud', {
20+
stackName: cloudName,
1921
description: 'This stack includes all of your Stacks cloud resources.',
2022
env: {
2123
account,

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

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export class StacksCloud extends Stack {
134134
if (this.apiCachePolicy)
135135
return this.apiCachePolicy
136136

137-
this.apiCachePolicy = new cloudfront.CachePolicy(this, 'StacksApiCachePolicy', {
137+
this.apiCachePolicy = new cloudfront.CachePolicy(this, 'ApiCachePolicy', {
138138
comment: 'Stacks API Cache Policy',
139139
cachePolicyName: `${this.appName}-${appEnv}-api-cache-policy`,
140140
// minTtl: config.cloud.cdn?.minTtl ? Duration.seconds(config.cloud.cdn.minTtl) : undefined,
@@ -148,7 +148,7 @@ export class StacksCloud extends Stack {
148148
}
149149

150150
deployApi() {
151-
const layer = new lambda.LayerVersion(this, 'StacksLambdaLayer', {
151+
const layer = new lambda.LayerVersion(this, 'BunLambdaLayer', {
152152
code: lambda.Code.fromAsset(p.projectStoragePath('framework/cloud/bun-lambda-layer.zip')),
153153
compatibleRuntimes: [lambda.Runtime.PROVIDED_AL2],
154154
compatibleArchitectures: [lambda.Architecture.ARM_64],
@@ -310,7 +310,7 @@ export class StacksCloud extends Stack {
310310
}
311311

312312
manageCertificate() {
313-
this.certificate = new acm.Certificate(this, 'StacksCertificate', {
313+
this.certificate = new acm.Certificate(this, 'Certificate', {
314314
domainName: this.domain,
315315
validation: acm.CertificateValidation.fromDns(this.zone),
316316
subjectAlternativeNames: [`www.${this.domain}`],
@@ -352,6 +352,12 @@ export class StacksCloud extends Stack {
352352
bucketName: `${this.appName}-logs-${appEnv}-${timestamp}`,
353353
removalPolicy: RemovalPolicy.DESTROY,
354354
autoDeleteObjects: true,
355+
blockPublicAccess: new s3.BlockPublicAccess({
356+
blockPublicAcls: false,
357+
ignorePublicAcls: true,
358+
blockPublicPolicy: true,
359+
restrictPublicBuckets: true,
360+
}),
355361
objectOwnership: s3.ObjectOwnership.BUCKET_OWNER_PREFERRED,
356362
})
357363
Tags.of(logBucket).add('daily-backup', 'true')
@@ -361,7 +367,7 @@ export class StacksCloud extends Stack {
361367

362368
// Daily 35 day retention
363369
const vault = new backup.BackupVault(this, 'BackupVault', {
364-
backupVaultName: `${this.appName}-${appEnv}-daily-backup-vault`,
370+
backupVaultName: `${this.appName}-${appEnv}-daily-backup-vault-${timestamp}`,
365371
// encryptionKey: this.storage?.encryptionKey,
366372
})
367373
const plan = backup.BackupPlan.daily35DayRetention(this, 'BackupPlan', vault)
@@ -597,7 +603,7 @@ export class StacksCloud extends Stack {
597603
// natGateways: 1,
598604
})
599605

600-
this.storage.fileSystem = new efs.FileSystem(this, 'StacksFileSystem', {
606+
this.storage.fileSystem = new efs.FileSystem(this, 'FileSystem', {
601607
vpc: this.vpc,
602608
fileSystemName: `${this.appName}-${appEnv}-efs`,
603609
removalPolicy: RemovalPolicy.DESTROY,
@@ -634,7 +640,7 @@ export class StacksCloud extends Stack {
634640
`),
635641
})
636642

637-
this.storage.accessPoint = new efs.AccessPoint(this, 'StacksAccessPoint', {
643+
this.storage.accessPoint = new efs.AccessPoint(this, 'FileSystemAccessPoint', {
638644
fileSystem: this.storage.fileSystem,
639645
path: '/',
640646
posixUser: {

.stacks/core/utils/src/base.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ export function assert(condition: boolean, message: string): asserts condition {
77

88
// export function noop() {}
99

10-
export function loop(times: number, callback: any) {
11-
[...Array(times)].forEach((item, i) => callback(i))
10+
export async function loop(times: number, callback: any) {
11+
[...Array(times)].forEach(async (item, i) => await callback(i))
1212
}

bun.lockb

-30.4 KB
Binary file not shown.

0 commit comments

Comments
 (0)