Skip to content

Commit b971840

Browse files
committed
chore: wip
1 parent 9e42974 commit b971840

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

.stacks/core/cloud/build-server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { log, runCommand } from '@stacksjs/cli'
22

3-
const result = await runCommand('bun build ./src/drivers/aws/runtime/server.ts --outdir src/drivers/aws/runtime --format esm --minify --target bun', {
3+
const result = await runCommand('bun build ./src/drivers/aws/runtime/server.ts --outdir src/drivers/aws/runtime --format esm --target bun', {
44
cwd: import.meta.dir,
55
})
66

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

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
aws_cloudfront as cloudfront,
1111
aws_lambda as lambda,
1212
aws_cloudfront_origins as origins,
13+
aws_efs as efs,
14+
aws_ec2 as ec2,
1315
aws_route53 as route53,
1416
aws_s3 as s3,
1517
aws_s3_deployment as s3deploy,
@@ -38,7 +40,10 @@ export class StacksCloud extends Stack {
3840
publicBucket: s3.Bucket
3941
privateBucket: s3.Bucket
4042
logBucket: s3.Bucket | undefined
43+
fileSystem?: efs.FileSystem | undefined
44+
accessPoint?: efs.AccessPoint | undefined
4145
}
46+
vpc!: ec2.Vpc
4247

4348
cdn: cloudfront.Distribution
4449
certificate!: acm.Certificate
@@ -65,6 +70,7 @@ export class StacksCloud extends Stack {
6570
this.manageCertificate()
6671
this.manageStorage()
6772
this.manageFirewall()
73+
this.manageFileSystem()
6874

6975
const { cdn, originAccessIdentity, cdnCachePolicy } = this.manageCdn()
7076
this.cdn = cdn
@@ -125,9 +131,10 @@ export class StacksCloud extends Stack {
125131
})
126132

127133
const serverFunction = new lambda.Function(this, 'StacksServer', {
134+
functionName: `${config.app.name}-${config.app.env}-server`,
128135
description: 'The Stacks Server',
129136
memorySize: 512,
130-
// filesystem: lambda.FileSystem.fromEfsAccessPoint(efsAccessPoint, '/mnt/efs'),
137+
filesystem: lambda.FileSystem.fromEfsAccessPoint(this.storage.accessPoint!, '/mnt/efs'),
131138
timeout: Duration.seconds(30),
132139
tracing: lambda.Tracing.ACTIVE,
133140
code: lambda.Code.fromAsset(p.projectStoragePath('framework/cloud/lambda.zip')),
@@ -294,6 +301,30 @@ export class StacksCloud extends Stack {
294301
})
295302
}
296303

304+
305+
manageFileSystem() {
306+
this.vpc = new ec2.Vpc(this, 'StacksVpc', {
307+
maxAzs: 2,
308+
natGateways: 1,
309+
})
310+
311+
this.storage.fileSystem = new efs.FileSystem(this, 'StacksFileSystem', {
312+
vpc: this.vpc,
313+
fileSystemName: `${config.app.name}-${config.app.env}-efs`,
314+
removalPolicy: RemovalPolicy.DESTROY,
315+
lifecyclePolicy: efs.LifecyclePolicy.AFTER_7_DAYS,
316+
})
317+
318+
this.storage.accessPoint = new efs.AccessPoint(this, 'StacksAccessPoint', {
319+
fileSystem: this.storage.fileSystem,
320+
path: '/public',
321+
posixUser: {
322+
uid: '1000',
323+
gid: '1000',
324+
},
325+
})
326+
}
327+
297328
manageCdn() {
298329
const originAccessIdentity = new cloudfront.OriginAccessIdentity(this, 'OAI')
299330

0 commit comments

Comments
 (0)