-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathstack-config.ts
132 lines (119 loc) · 3.29 KB
/
stack-config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
export interface StackConfig {
/**
* Whether to use a t4g.nano NAT instance instead of NAT Gateway.
*
* @default - Not use a NAT Instance (use a NAT Gateway)
*/
useNatIncetance?: boolean;
/**
* Whether to use Fargate Spot for Langfuse web/server and ClickHouse.
*
* @default - Not use Fargate Spot
*/
enableFargateSpot?: boolean;
/**
* The vCPU of Fargate Task Definition for Langfuse web/server and ClickHouse.
*
* Langfuse recommend that you should have at least 2 CPUs for production environments.
*
* @default 1024
* @see https://langfuse.com/self-hosting/infrastructure/containers#recommended-sizing
*/
taskDefCpu?: number;
/**
* The amount (in MiN) of Memory of Fargate Task Definition for Langfuse web/server and ClickHouse.
*
* Langfuse recommend that you should have at 4 GB of RAM for production environments.
*
* @default 2048
* @see https://langfuse.com/self-hosting/infrastructure/containers#recommended-sizing
*/
taskDefMemoryLimitMiB?: number;
/**
* The number of task for Langfuse Web.
*
* Langfuse recommend that you should have at least two containers for production environments.
*
* @default undefined - ECS default setting is 1
* @see https://langfuse.com/self-hosting/infrastructure/containers#recommended-sizing
*/
langfuseWebTaskCount?: number;
/**
* The Docker image tag for the Langfuse application.
*
* @default 'latest'
*/
langfuseImageTag?: string;
/**
* The Docker image tag for the ClickHouse database.
*
* @default 'latest'
*/
clickhouseImageTag?: string;
/**
* The logging level for the Langfuse application.
*
* @default LOG_LEVEL.INFO
*/
langfuseLogLevel?: LOG_LEVEL;
/**
* Whether to create a Bastion Host for secure access to the infrastructure.
*
* @default - Not created
*/
createBastion?: boolean;
/**
* Whether Aurora Serverless scales to zero when idle to reduce costs.
*
* @default - Scaling to zero is disabled
* @see https://aws.amazon.com/blogs/database/introducing-scaling-to-0-capacity-with-amazon-aurora-serverless-v2/
*/
auroraScalesToZero?: boolean;
/**
* Whether the ElastiCache Cluset is deployed in a Multi-AZ configuration for high availability.
*
* @default - Single-AZ if not specified.
*/
cacheMultiAz?: boolean;
}
export enum LOG_LEVEL {
TRACE = 'trace',
DEBUG = 'debug',
INFO = 'info',
WARN = 'warn',
ERROR = 'error',
FATL = 'fatal',
}
const stackConfigMap: Record<string, StackConfig> = {
dev: {
useNatIncetance: true,
enableFargateSpot: true,
createBastion: true,
langfuseLogLevel: LOG_LEVEL.DEBUG,
langfuseImageTag: '3.28.0',
auroraScalesToZero: true,
cacheMultiAz: false,
},
stg: {
createBastion: true,
auroraScalesToZero: true,
cacheMultiAz: false,
},
prod: {
taskDefCpu: 2048,
taskDefMemoryLimitMiB: 4096,
langfuseWebTaskCount: 2,
createBastion: true,
langfuseLogLevel: LOG_LEVEL.INFO,
langfuseImageTag: '3.28.0',
auroraScalesToZero: false,
cacheMultiAz: false,
},
};
export function getStackConfig(envName: string): StackConfig {
const config = stackConfigMap[envName];
if (!config) {
throw new Error(`StackConfig does not exist. envName:${envName}`);
}
return config;
}