@@ -65,32 +65,147 @@ export const tsCloud: TsCloudConfig = {
6565 * Define your cloud resources here
6666 */
6767 infrastructure : {
68+ /**
69+ * Compute Configuration
70+ *
71+ * Defines the instances running your Stacks/Bun application.
72+ * When instances > 1, load balancer is automatically enabled.
73+ *
74+ * @example Single instance (development/staging)
75+ * compute: { instances: 1, size: 'micro' }
76+ *
77+ * @example Multiple instances with auto-scaling (production)
78+ * compute: {
79+ * instances: 3,
80+ * size: 'small',
81+ * autoScaling: { min: 2, max: 10, scaleUpThreshold: 70 },
82+ * }
83+ *
84+ * @example Mixed instance fleet for cost optimization
85+ * compute: {
86+ * instances: 3,
87+ * fleet: [
88+ * { size: 'small', weight: 1 },
89+ * { size: 'medium', weight: 2 },
90+ * { size: 'small', weight: 1, spot: true },
91+ * ],
92+ * spotConfig: {
93+ * baseCapacity: 1, // Always keep 1 on-demand
94+ * onDemandPercentage: 50, // 50% on-demand, 50% spot
95+ * strategy: 'capacity-optimized',
96+ * },
97+ * }
98+ */
99+ compute : {
100+ instances : 1 ,
101+ size : 'micro' , // Provider-agnostic: 'nano', 'micro', 'small', 'medium', 'large', 'xlarge', '2xlarge'
102+ disk : {
103+ size : 20 ,
104+ type : 'ssd' , // Provider-agnostic: 'standard', 'ssd', 'premium'
105+ encrypted : true ,
106+ } ,
107+ // Uncomment for auto-scaling:
108+ // autoScaling: {
109+ // min: 1,
110+ // max: 5,
111+ // scaleUpThreshold: 70,
112+ // scaleDownThreshold: 30,
113+ // },
114+ // Uncomment for mixed instance fleet:
115+ // fleet: [
116+ // { size: 'micro', weight: 1 },
117+ // { size: 'small', weight: 2 },
118+ // { size: 'micro', weight: 1, spot: true },
119+ // ],
120+ // spotConfig: {
121+ // baseCapacity: 1,
122+ // onDemandPercentage: 50,
123+ // strategy: 'capacity-optimized',
124+ // },
125+ } ,
126+
127+ /**
128+ * Load Balancer Configuration
129+ *
130+ * Controls whether to use an Application Load Balancer (ALB) for traffic distribution.
131+ * Automatically enabled when compute.instances > 1.
132+ *
133+ * Benefits of ALB:
134+ * - SSL termination with ACM certificates (free)
135+ * - Health checks and automatic failover
136+ * - HTTP to HTTPS redirect
137+ * - Multiple target support
138+ *
139+ * When to disable:
140+ * - Cost optimization (ALB costs ~$16/month minimum)
141+ * - Simple single-instance deployments
142+ * - Using Let's Encrypt for SSL instead of ACM
143+ */
144+ loadBalancer : {
145+ enabled : true ,
146+ type : 'application' ,
147+ healthCheck : {
148+ path : '/health' ,
149+ interval : 30 ,
150+ healthyThreshold : 2 ,
151+ unhealthyThreshold : 5 ,
152+ } ,
153+ } ,
154+
155+ /**
156+ * SSL/TLS Configuration
157+ *
158+ * Supports two providers:
159+ * - 'acm': AWS Certificate Manager (free, requires ALB or CloudFront)
160+ * - 'letsencrypt': Free certificates (works without ALB, runs on EC2)
161+ *
162+ * When loadBalancer.enabled = true:
163+ * - Uses ACM by default (recommended)
164+ * - Certificates are automatically requested and validated via DNS
165+ * - HTTP to HTTPS redirect handled by ALB
166+ *
167+ * When loadBalancer.enabled = false:
168+ * - Uses Let's Encrypt by default
169+ * - Certificates are obtained and renewed automatically on EC2
170+ * - Requires port 80 for HTTP-01 challenge or DNS for DNS-01
171+ */
172+ ssl : {
173+ enabled : true ,
174+ provider : 'acm' , // 'acm' | 'letsencrypt'
175+ domains : [ 'stacksjs.com' , 'www.stacksjs.com' ] ,
176+ redirectHttp : true ,
177+ // Uncomment for existing ACM certificate:
178+ // certificateArn: 'arn:aws:acm:us-east-1:...',
179+ // Let's Encrypt configuration (used when provider: 'letsencrypt' or loadBalancer.enabled: false)
180+ letsEncrypt : {
181+ email : 'admin@stacksjs.com' ,
182+ staging : false , // Set to true for testing
183+ autoRenew : true ,
184+ } ,
185+ } ,
186+
187+ /**
188+ * DNS Configuration
189+ */
190+ dns : {
191+ domain : 'stacksjs.com' ,
192+ hostedZoneId : 'Z01455702Q7952O6RCY37' , // Route53 hosted zone for stacksjs.com
193+ } ,
194+
68195 /**
69196 * Storage Configuration
70197 * S3 buckets for frontend, assets, uploads, etc.
71198 */
72199 storage : {
73- 'frontend' : {
74- public : true ,
75- website : true ,
76- encryption : true ,
77- versioning : false ,
78- } ,
79200 'assets' : {
80- public : true ,
81- website : false ,
82201 encryption : true ,
83202 versioning : false ,
84203 } ,
85204 'uploads' : {
86- public : false ,
87- website : false ,
88205 encryption : true ,
89206 versioning : true ,
90207 } ,
91208 'backups' : {
92- public : false ,
93- website : false ,
94209 encryption : true ,
95210 versioning : true ,
96211 } ,
@@ -136,24 +251,13 @@ export const tsCloud: TsCloudConfig = {
136251 * CloudFront distribution for global content delivery
137252 */
138253 cdn : {
139- 'frontend' : {
140- origin : 'stacks-production-frontend.s3.us-east-1.amazonaws.com' ,
141- customDomain : 'stacks.example.com' , // Update with your domain
142- } ,
254+ // Uncomment to enable CloudFront CDN
255+ // 'frontend': {
256+ // origin: 'stacks-production-frontend.s3.us-east-1.amazonaws.com',
257+ // customDomain: 'cdn.stacks-js.org',
258+ // },
143259 } ,
144260
145- /**
146- * API Gateway Configuration (optional)
147- *
148- * Note: Stacks handles APIs through Bun serve with ./routes
149- * API Gateway is only needed if you're using Lambda functions for your API.
150- * For most Stacks apps, you don't need this.
151- */
152- // api: {
153- // type: 'rest',
154- // cors: true,
155- // },
156-
157261 /**
158262 * Monitoring Configuration (optional)
159263 */
@@ -176,15 +280,10 @@ export const tsCloud: TsCloudConfig = {
176280 */
177281 sites : {
178282 main : {
179- root : '/var/www/main ' ,
283+ root : '/var/www/app ' ,
180284 path : '/' ,
181- domain : 'stacks.example .com' ,
285+ domain : 'stacksjs .com' ,
182286 } ,
183- // api: {
184- // root: '/var/www/api',
185- // path: '/api',
186- // domain: 'api.stacks.example.com',
187- // },
188287 } ,
189288}
190289
0 commit comments