Skip to content

Commit c1180b0

Browse files
committed
chore: wip
1 parent 8e85127 commit c1180b0

File tree

1 file changed

+17
-44
lines changed

1 file changed

+17
-44
lines changed

storage/framework/core/cloud/src/cloud/compute.ts

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -26,27 +26,22 @@ export class ComputeStack {
2626
throw new Error('The file system is missing. Please make sure it was created properly.')
2727

2828
const cluster = new ecs.Cluster(scope, 'StacksCluster', {
29+
clusterName: `${props.slug}-${props.appEnv}-web-server-cluster`,
2930
vpc,
3031
})
3132

3233
const taskDefinition = new ecs.FargateTaskDefinition(scope, 'TaskDef', {
3334
memoryLimitMiB: 512, // Match your Lambda memory size
3435
cpu: 256, // Choose an appropriate value
35-
portMappings: [{ containerPort: 80 }],
3636
})
3737

3838
const container = taskDefinition.addContainer('WebServerContainer', {
3939
image: ecs.ContainerImage.fromAsset(p.frameworkPath('server')),
40-
// You can add environment variables, logging, etc., here
41-
})
42-
43-
container.addPortMappings({
44-
containerPort: 80, // or whatever port your application listens on
45-
// hostPort: 80, // Optional: Specify if you need to map to a specific host port
46-
// protocol: ecs.Protocol.TCP, // Optional: Specify protocol, defaults to TCP
40+
portMappings: [{ containerPort: 80 }],
4741
})
4842

4943
const fargateService = new ecs_patterns.ApplicationLoadBalancedFargateService(scope, 'FargateService', {
44+
serviceName: `${props.slug}-${props.appEnv}-fargate-service`,
5045
cluster,
5146
taskDefinition,
5247
desiredCount: 1, // Start with 1 task instance
@@ -71,52 +66,30 @@ export class ComputeStack {
7166
readOnly: false,
7267
})
7368

74-
// this.apiServer = new lambda.Function(scope, 'WebServer', {
75-
// functionName: `${props.slug}-${props.appEnv}-web-server`,
76-
// description: 'The web server for the Stacks application',
77-
// code: lambda.Code.fromAssetImage(p.frameworkPath('server')),
78-
// handler: lambda.Handler.FROM_IMAGE,
79-
// runtime: lambda.Runtime.FROM_IMAGE,
80-
// vpc,
81-
// memorySize: 512, // replace with your actual memory size
82-
// timeout: Duration.minutes(5), // replace with your actual timeout
83-
// logRetention: logs.RetentionDays.ONE_WEEK,
84-
// architecture: lambda.Architecture.ARM_64,
85-
// // filesystem: lambda.FileSystem.fromEfsAccessPoint(props.accessPoint, '/mnt/efs'),
86-
// })
87-
8869
const keysToRemove = ['_HANDLER', '_X_AMZN_TRACE_ID', 'AWS_REGION', 'AWS_EXECUTION_ENV', 'AWS_LAMBDA_FUNCTION_NAME', 'AWS_LAMBDA_FUNCTION_MEMORY_SIZE', 'AWS_LAMBDA_FUNCTION_VERSION', 'AWS_LAMBDA_INITIALIZATION_TYPE', 'AWS_LAMBDA_LOG_GROUP_NAME', 'AWS_LAMBDA_LOG_STREAM_NAME', 'AWS_ACCESS_KEY', 'AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_SESSION_TOKEN', 'AWS_LAMBDA_RUNTIME_API', 'LAMBDA_TASK_ROOT', 'LAMBDA_RUNTIME_DIR', '_']
8970
keysToRemove.forEach(key => delete env[key as EnvKey])
9071

91-
// const secrets = new secretsmanager.Secret(scope, 'StacksSecrets', {
92-
// secretName: `${props.slug}-${props.appEnv}-secrets`,
93-
// description: 'Secrets for the Stacks application',
94-
// generateSecretString: {
95-
// secretStringTemplate: JSON.stringify(env),
96-
// generateStringKey: Object.keys(env).join(',').length.toString(),
97-
// },
98-
// })
99-
100-
// secrets.grantRead(this.apiServer)
101-
// this.apiServer.addEnvironment('SECRETS_ARN', secrets.secretArn)
72+
const secrets = new secretsmanager.Secret(scope, 'StacksSecrets', {
73+
secretName: `${props.slug}-${props.appEnv}-secrets`,
74+
description: 'Secrets for the Stacks application',
75+
generateSecretString: {
76+
secretStringTemplate: JSON.stringify(env),
77+
generateStringKey: Object.keys(env).join(',').length.toString(),
78+
},
79+
})
10280

103-
// this.apiServerUrl = new lambda.FunctionUrl(scope, 'StacksServerUrl', {
104-
// function: this.apiServer,
105-
// authType: lambda.FunctionUrlAuthType.NONE, // becomes a public API
106-
// cors: {
107-
// allowedOrigins: ['*'],
108-
// },
109-
// })
81+
secrets.grantRead(fargateService.taskDefinition.executionRole!)
82+
container.addEnvironment('SECRETS_ARN', secrets.secretArn)
11083

11184
const apiPrefix = 'api'
11285
new Output(scope, 'ApiUrl', {
11386
value: `https://${props.domain}/${apiPrefix}`,
11487
description: 'The URL of the deployed application',
11588
})
11689

117-
// new Output(scope, 'ApiVanityUrl', {
118-
// value: this.apiServerUrl.url,
119-
// description: 'The Vanity URL of the deployed application',
120-
// })
90+
new Output(scope, 'ApiVanityUrl', {
91+
value: '',
92+
description: 'The Vanity URL of the deployed application',
93+
})
12194
}
12295
}

0 commit comments

Comments
 (0)