@thunder-so/thunder 1.3.0 → 1.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,198 @@
1
+ {
2
+ "languages": {
3
+ "python": {
4
+ "name": "pyright",
5
+ "command": "pyright-langserver",
6
+ "args": [
7
+ "--stdio"
8
+ ],
9
+ "file_extensions": [
10
+ "py"
11
+ ],
12
+ "project_patterns": [
13
+ "pyproject.toml",
14
+ "setup.py",
15
+ "requirements.txt",
16
+ "pyrightconfig.json"
17
+ ],
18
+ "exclude_patterns": [
19
+ "**/__pycache__/**",
20
+ "**/venv/**",
21
+ "**/.venv/**",
22
+ "**/.pytest_cache/**"
23
+ ],
24
+ "multi_workspace": false,
25
+ "initialization_options": {},
26
+ "request_timeout_secs": 60
27
+ },
28
+ "ruby": {
29
+ "name": "solargraph",
30
+ "command": "solargraph",
31
+ "args": [
32
+ "stdio"
33
+ ],
34
+ "file_extensions": [
35
+ "rb"
36
+ ],
37
+ "project_patterns": [
38
+ "Gemfile",
39
+ "Rakefile"
40
+ ],
41
+ "exclude_patterns": [
42
+ "**/vendor/**",
43
+ "**/tmp/**"
44
+ ],
45
+ "multi_workspace": false,
46
+ "initialization_options": {},
47
+ "request_timeout_secs": 60
48
+ },
49
+ "cpp": {
50
+ "name": "clangd",
51
+ "command": "clangd",
52
+ "args": [
53
+ "--background-index"
54
+ ],
55
+ "file_extensions": [
56
+ "cpp",
57
+ "cc",
58
+ "cxx",
59
+ "c",
60
+ "h",
61
+ "hpp",
62
+ "hxx"
63
+ ],
64
+ "project_patterns": [
65
+ "CMakeLists.txt",
66
+ "compile_commands.json",
67
+ "Makefile"
68
+ ],
69
+ "exclude_patterns": [
70
+ "**/build/**",
71
+ "**/cmake-build-**/**"
72
+ ],
73
+ "multi_workspace": false,
74
+ "initialization_options": {},
75
+ "request_timeout_secs": 60
76
+ },
77
+ "typescript": {
78
+ "name": "typescript-language-server",
79
+ "command": "typescript-language-server",
80
+ "args": [
81
+ "--stdio"
82
+ ],
83
+ "file_extensions": [
84
+ "ts",
85
+ "js",
86
+ "tsx",
87
+ "jsx"
88
+ ],
89
+ "project_patterns": [
90
+ "package.json",
91
+ "tsconfig.json"
92
+ ],
93
+ "exclude_patterns": [
94
+ "**/node_modules/**",
95
+ "**/dist/**"
96
+ ],
97
+ "multi_workspace": false,
98
+ "initialization_options": {
99
+ "preferences": {
100
+ "disableSuggestions": false
101
+ }
102
+ },
103
+ "request_timeout_secs": 60
104
+ },
105
+ "java": {
106
+ "name": "jdtls",
107
+ "command": "jdtls",
108
+ "args": [],
109
+ "file_extensions": [
110
+ "java"
111
+ ],
112
+ "project_patterns": [
113
+ "pom.xml",
114
+ "build.gradle",
115
+ "build.gradle.kts",
116
+ ".project"
117
+ ],
118
+ "exclude_patterns": [
119
+ "**/target/**",
120
+ "**/build/**",
121
+ "**/.gradle/**"
122
+ ],
123
+ "multi_workspace": false,
124
+ "initialization_options": {
125
+ "settings": {
126
+ "java": {
127
+ "compile": {
128
+ "nullAnalysis": {
129
+ "mode": "automatic"
130
+ }
131
+ },
132
+ "configuration": {
133
+ "annotationProcessing": {
134
+ "enabled": true
135
+ }
136
+ }
137
+ }
138
+ }
139
+ },
140
+ "request_timeout_secs": 60
141
+ },
142
+ "rust": {
143
+ "name": "rust-analyzer",
144
+ "command": "rust-analyzer",
145
+ "args": [],
146
+ "file_extensions": [
147
+ "rs"
148
+ ],
149
+ "project_patterns": [
150
+ "Cargo.toml"
151
+ ],
152
+ "exclude_patterns": [
153
+ "**/target/**"
154
+ ],
155
+ "multi_workspace": false,
156
+ "initialization_options": {
157
+ "cargo": {
158
+ "buildScripts": {
159
+ "enable": true
160
+ }
161
+ },
162
+ "diagnostics": {
163
+ "enable": true,
164
+ "enableExperimental": true
165
+ },
166
+ "workspace": {
167
+ "symbol": {
168
+ "search": {
169
+ "scope": "workspace"
170
+ }
171
+ }
172
+ }
173
+ },
174
+ "request_timeout_secs": 60
175
+ },
176
+ "go": {
177
+ "name": "gopls",
178
+ "command": "gopls",
179
+ "args": [],
180
+ "file_extensions": [
181
+ "go"
182
+ ],
183
+ "project_patterns": [
184
+ "go.mod",
185
+ "go.sum"
186
+ ],
187
+ "exclude_patterns": [
188
+ "**/vendor/**"
189
+ ],
190
+ "multi_workspace": false,
191
+ "initialization_options": {
192
+ "usePlaceholders": true,
193
+ "completeUnimported": true
194
+ },
195
+ "request_timeout_secs": 60
196
+ }
197
+ }
198
+ }
package/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  Build full-stack apps on your own AWS.
9
9
 
10
- Thunder is a CDK library and CLI for deploying modern web applications on AWS. One library to rule them all: [Static SPAs](#static), [Lambda Functions](#lambda), [Containers on Fargate](#fargate) and [EC2](#ec2), and [Full-stack Frameworks](#full-stack-frameworks).
10
+ Thunder is a CDK library and CLI for deploying modern web applications on AWS. One library to rule them all: [Static SPAs](#static), [Lambda Functions](#lambda), [Containers on Fargate](#fargate) and [EC2](#ec2), and [Serverless Full-stack Frameworks](#serverless-frameworks).
11
11
 
12
12
  ## Table of Contents
13
13
 
@@ -19,8 +19,7 @@ Thunder is a CDK library and CLI for deploying modern web applications on AWS. O
19
19
  - [Lambda](#lambda) - API Gateway + Lambda
20
20
  - [Fargate](#fargate) - ECS Fargate + ALB + CloudFront
21
21
  - [EC2](#ec2) - EC2 + Docker + Elastic IP
22
- - [Nuxt](#nuxt) - Serverless full-stack with Lambda
23
- - [Astro](#astro) - Serverless full-stack SSR with Lambda
22
+ - [Serverless Frameworks](#serverless-frameworks) - Full-stack meta-frameworks with Lambda + S3 + CloudFront
24
23
  - [Template](#template) - Coolify-style templates
25
24
  - [CLI Commands](#cli-commands)
26
25
  - [Documentation](#documentation)
@@ -28,7 +27,7 @@ Thunder is a CDK library and CLI for deploying modern web applications on AWS. O
28
27
 
29
28
  ## Features
30
29
 
31
- - **Constructs:** One-line deployment for `Static`, `Lambda`, `Fargate`, `EC2`, `Nuxt`, and `Astro`.
30
+ - **Constructs:** One-line deployment for `Static`, `Lambda`, `Fargate`, `EC2`, `Serverless`, and framework-specific constructs.
32
31
  - **Thunder CLI (`th`):** Context-aware CLI for initializing, deploying, and managing your infrastructure.
33
32
  - **VPC Link Pattern:** Easily connect your compute resources to a shared VPC.
34
33
  - **High-Performance Serving:** Pre-configured [CloudFront](https://aws.amazon.com/cloudfront/) distributions with OAC, security headers, and edge optimizations.
@@ -39,7 +38,7 @@ Thunder is a CDK library and CLI for deploying modern web applications on AWS. O
39
38
  - **Static:** Vite (React, Vue, Svelte, Solid), Next.js (SSG), Astro (SSG), Gatsby.
40
39
  - **Serverless:** Node.js Lambda, Bun, Container-based Lambda.
41
40
  - **Containers:** [ECS Fargate](https://aws.amazon.com/fargate/) with ALB, Docker on [EC2](https://aws.amazon.com/ec2/) with Elastic IP.
42
- - **Full-stack SSR:** [Nuxt.js](https://nuxt.com/), [Astro](https://astro.build/) (SSR), and extensibility for SvelteKit, TanStack Start, AnalogJS.
41
+ - **Full-stack SSR:** [Nuxt](https://nuxt.com/), [Astro](https://astro.build/), [TanStack Start](https://tanstack.com/start), [SvelteKit](https://kit.svelte.dev/), [Solid Start](https://start.solidjs.com/), [AnalogJS](https://analogjs.org/).
43
42
 
44
43
  ## Quick Start
45
44
 
@@ -267,87 +266,14 @@ new Ec2(new Cdk.App(), 'myapp-api-prod-stack', config);
267
266
 
268
267
  ---
269
268
 
270
- ### Full-Stack Frameworks
271
-
272
- #### Nuxt
273
-
274
- Deploy [Nuxt.js](https://nuxt.com/) SSR applications with hybrid rendering - Lambda for server-side and S3 for static assets.
275
-
276
- **Best for:** Vue-based full-stack applications with server-side rendering
277
-
278
- **AWS Resources:**
279
- - [Lambda Function](https://aws.amazon.com/lambda/) - SSR server
280
- - [S3 Bucket](https://aws.amazon.com/s3/) - Static assets
281
- - [CloudFront Distribution](https://aws.amazon.com/cloudfront/) - Unified CDN
282
- - [API Gateway](https://aws.amazon.com/api-gateway/) - HTTP API
283
-
284
- **Example:**
285
- ```typescript
286
- import { Cdk, Nuxt, type NuxtProps } from '@thunder-so/thunder';
287
-
288
- const config: NuxtProps = {
289
- env: { account: '123456789012', region: 'us-east-1' },
290
- application: 'myapp',
291
- service: 'web',
292
- environment: 'prod',
293
- rootDir: '.',
294
-
295
- serverProps: {
296
- runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
297
- architecture: Cdk.aws_lambda.Architecture.ARM_64,
298
- memorySize: 1792,
299
- timeout: 10,
300
- keepWarm: true,
301
- },
302
-
303
- // Optional: Custom domain
304
- domain: 'example.com',
305
- globalCertificateArn: 'arn:aws:acm:us-east-1:...',
306
- hostedZoneId: 'Z123456789',
307
- };
308
-
309
- new Nuxt(new Cdk.App(), 'myapp-web-prod-stack', config);
310
- ```
311
-
312
- ---
313
-
314
- #### Astro
315
-
316
- Deploy [Astro](https://astro.build/) SSR applications with the same infrastructure pattern as Nuxt.
317
-
318
- **Best for:** Content-focused websites with server-side rendering and islands architecture
319
-
320
- **AWS Resources:** Same as [Nuxt](#nuxt)
321
-
322
- **Example:**
323
- ```typescript
324
- import { Cdk, Astro, type NuxtProps as AstroProps } from '@thunder-so/thunder';
325
-
326
- const config: AstroProps = {
327
- env: { account: '123456789012', region: 'us-east-1' },
328
- application: 'myapp',
329
- service: 'web',
330
- environment: 'prod',
331
- rootDir: '.',
332
-
333
- serverProps: {
334
- runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
335
- architecture: Cdk.aws_lambda.Architecture.ARM_64,
336
- memorySize: 1024,
337
- },
338
- };
339
-
340
- new Astro(new Cdk.App(), 'myapp-web-prod-stack', config);
341
- ```
342
-
343
- ---
344
-
345
269
  ### Serverless Frameworks
346
270
 
347
271
  Deploy modern meta-frameworks as serverless applications with unified infrastructure - Lambda for server-side rendering and S3 for static assets, all behind CloudFront.
348
272
 
349
273
  **Best for:** Full-stack applications with server-side rendering, API routes, and static asset optimization
350
274
 
275
+ **Supported Frameworks:** Nuxt, Astro, TanStack Start, SvelteKit, Solid Start, AnalogJS, or any Vite/Nitro-based framework using the generic `Serverless` construct.
276
+
351
277
  **AWS Resources:**
352
278
  - [Lambda Function](https://aws.amazon.com/lambda/) - SSR server with container support
353
279
  - [S3 Bucket](https://aws.amazon.com/s3/) - Static assets with OAC
@@ -360,7 +286,6 @@ Deploy modern meta-frameworks as serverless applications with unified infrastruc
360
286
  - [TanStack Start](https://tanstack.com/start) - Type-safe full-stack React framework
361
287
  - [Nuxt](https://nuxt.com/) - Vue-based full-stack framework
362
288
  - [Astro](https://astro.build/) - Content-focused web framework with islands architecture
363
- - [React Router v7](https://reactrouter.com/) - Full-stack React framework with nested routing
364
289
  - [SvelteKit](https://kit.svelte.dev/) - Svelte-based full-stack framework
365
290
  - [Solid Start](https://start.solidjs.com/) - SolidJS full-stack framework
366
291
  - [AnalogJS](https://analogjs.org/) - Angular-based full-stack framework
@@ -460,43 +385,6 @@ const config: AstroProps = {
460
385
  new Astro(new Cdk.App(), 'myapp-web-prod-stack', config);
461
386
  ```
462
387
 
463
- #### React Router
464
-
465
- Deploy [React Router v7](https://reactrouter.com/) framework mode applications with server-side rendering and API routes.
466
-
467
- **Best for:** React applications with nested routing, server-side rendering, and modern React Router patterns
468
-
469
- **AWS Resources:** Same as [TanStack Start](#tanstack-start)
470
-
471
- **Example:**
472
- ```typescript
473
- import { Cdk, ReactRouter, type ReactRouterProps } from '@thunder-so/thunder';
474
-
475
- const config: ReactRouterProps = {
476
- env: { account: '123456789012', region: 'us-east-1' },
477
- application: 'myapp',
478
- service: 'web',
479
- environment: 'prod',
480
- rootDir: '.',
481
-
482
- serverProps: {
483
- runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
484
- architecture: Cdk.aws_lambda.Architecture.ARM_64,
485
- memorySize: 1024,
486
- timeout: 10,
487
- keepWarm: true,
488
- variables: [{ NODE_ENV: 'production' }],
489
- },
490
-
491
- // Optional: Custom domain
492
- domain: 'myapp.com',
493
- globalCertificateArn: 'arn:aws:acm:us-east-1:...',
494
- hostedZoneId: 'Z123456789',
495
- };
496
-
497
- new ReactRouter(new Cdk.App(), 'myapp-web-prod-stack', config);
498
- ```
499
-
500
388
  #### SvelteKit
501
389
 
502
390
  **Example:**
@@ -654,6 +542,60 @@ main();
654
542
 
655
543
  For detailed documentation on each construct and advanced configurations, see the [Wiki](https://github.com/thunder-so/thunder/wiki).
656
544
 
545
+ ### Static
546
+
547
+ | Guide | Description |
548
+ | :--- | :--- |
549
+ | [static-basic.md](./docs/static-basic.md) | Deploy a static site or SPA to S3 + CloudFront |
550
+ | [static-edge-functions.md](./docs/static-edge-functions.md) | Redirects, rewrites, and custom headers via Lambda@Edge |
551
+ | [static-full.md](./docs/static-full.md) | Full `StaticProps` configuration reference |
552
+
553
+ ### Lambda
554
+
555
+ | Guide | Description |
556
+ | :--- | :--- |
557
+ | [lambda-basic.md](./docs/lambda-basic.md) | Deploy a serverless API with Lambda + API Gateway |
558
+ | [lambda-containers.md](./docs/lambda-containers.md) | Container images and Bun runtime |
559
+ | [lambda-full.md](./docs/lambda-full.md) | Full `LambdaProps` configuration reference |
560
+
561
+ ### Fargate
562
+
563
+ | Guide | Description |
564
+ | :--- | :--- |
565
+ | [fargate-basic.md](./docs/fargate-basic.md) | Deploy a containerized service on ECS Fargate |
566
+ | [fargate-nixpacks.md](./docs/fargate-nixpacks.md) | Auto-generate Dockerfiles with Nixpacks |
567
+ | [fargate-full.md](./docs/fargate-full.md) | Full `FargateProps` configuration reference |
568
+
569
+ ### Serverless (Full-Stack Frameworks)
570
+
571
+ | Guide | Description |
572
+ | :--- | :--- |
573
+ | [serverless.md](./docs/serverless.md) | Deploy full-stack meta-frameworks with SSR |
574
+
575
+ ### Framework Guides
576
+
577
+ **Static Deployment:**
578
+ - [Next.js Static](./docs/frameworks/nextjs-static.md)
579
+ - [Astro Static](./docs/frameworks/astro-static.md)
580
+
581
+ **Serverless (Lambda + S3 + CloudFront):**
582
+ - [Nuxt](./docs/frameworks/nuxt-serverless.md)
583
+ - [Astro SSR](./docs/frameworks/astro-serverless.md)
584
+ - [TanStack Start](./docs/frameworks/tanstack-start-serverless.md)
585
+ - [SvelteKit](./docs/frameworks/sveltekit-serverless.md)
586
+ - [Solid Start](./docs/frameworks/solidstart-serverless.md)
587
+ - [AnalogJS](./docs/frameworks/analogjs-serverless.md)
588
+
589
+ **Fargate (Containers):**
590
+ - [Next.js with Dockerfile](./docs/frameworks/nextjs-fargate-dockerfile.md)
591
+ - [Next.js with Nixpacks](./docs/frameworks/nextjs-fargate-nixpacks.md)
592
+ - [Astro](./docs/frameworks/astro-fargate.md)
593
+ - [Nuxt](./docs/frameworks/nuxt-fargate.md)
594
+ - [TanStack Start](./docs/frameworks/tanstack-start-fargate.md)
595
+ - [SvelteKit](./docs/frameworks/sveltekit-fargate.md)
596
+ - [Solid Start](./docs/frameworks/solidstart-fargate.md)
597
+ - [AnalogJS](./docs/frameworks/analogjs-fargate.md)
598
+
657
599
  ## License
658
600
 
659
601
  Apache-2.0
@@ -0,0 +1,222 @@
1
+ # Deploy Containerized Apps to AWS ECS Fargate
2
+
3
+ Run any Docker container as a production web service on [AWS ECS Fargate](https://aws.amazon.com/fargate/) - serverless containers with an [Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/application-load-balancer/) in front. No EC2 instances, no cluster management, and automatic health checks and restarts.
4
+
5
+ Works with any language or framework you can containerize: Next.js, Express, NestJS, Django, Rails, Go, Rust, and more.
6
+
7
+ ## AWS Resources
8
+
9
+ | Resource | Purpose |
10
+ |---|---|
11
+ | [ECS Cluster](https://aws.amazon.com/ecs/) | Container orchestration |
12
+ | [Fargate Task](https://aws.amazon.com/fargate/) | Serverless container runtime |
13
+ | [Application Load Balancer](https://aws.amazon.com/elasticloadbalancing/) | Public HTTP/HTTPS endpoint, health checks |
14
+ | [VPC](https://aws.amazon.com/vpc/) | Network isolation (created automatically if not provided) |
15
+ | [CloudWatch Logs](https://aws.amazon.com/cloudwatch/) | Container logs, retained for 1 week |
16
+ | [ACM Certificate](https://aws.amazon.com/certificate-manager/) | SSL for custom domain (optional) |
17
+ | [Route53](https://aws.amazon.com/route53/) | DNS A record (optional) |
18
+
19
+ ## Prerequisites
20
+
21
+ - [Docker](https://docs.docker.com/get-docker/) installed and running locally
22
+ - [AWS CLI](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html) configured
23
+ - [AWS CDK](https://docs.aws.amazon.com/cdk/v2/guide/getting_started.html) bootstrapped:
24
+ ```bash
25
+ cdk bootstrap aws://YOUR_ACCOUNT_ID/us-east-1
26
+ ```
27
+
28
+ ## Installation
29
+
30
+ ```bash
31
+ bun add @thunder-so/thunder --development
32
+ # or
33
+ npm install @thunder-so/thunder --save-dev
34
+ ```
35
+
36
+ ## Dockerfile
37
+
38
+ Your app needs a `Dockerfile`. Here's a production-ready example for a Node.js app:
39
+
40
+ ```dockerfile
41
+ # Dockerfile
42
+
43
+ # Build stage
44
+ FROM public.ecr.aws/docker/library/node:22-alpine AS builder
45
+ WORKDIR /app
46
+ COPY . .
47
+ RUN corepack enable && corepack prepare pnpm@latest --activate
48
+ RUN pnpm install
49
+ RUN pnpm run build
50
+
51
+ # Production stage
52
+ FROM public.ecr.aws/docker/library/node:22-alpine AS runner
53
+ WORKDIR /app
54
+ ENV NODE_ENV=production
55
+ RUN corepack enable && corepack prepare pnpm@latest --activate
56
+ COPY --from=builder /app/ ./
57
+ EXPOSE 3000
58
+ CMD ["pnpm", "start"]
59
+ ```
60
+
61
+ Add a `.dockerignore` to keep the build context lean:
62
+
63
+ ```
64
+ .git
65
+ node_modules
66
+ cdk.out
67
+ stack
68
+ .DS_Store
69
+ ```
70
+
71
+ ## Stack File
72
+
73
+ ```typescript
74
+ import { Cdk, Fargate, type FargateProps } from '@thunder-so/thunder';
75
+
76
+ const config: FargateProps = {
77
+ env: {
78
+ account: '123456789012',
79
+ region: 'us-east-1',
80
+ },
81
+ application: 'myapp',
82
+ service: 'api',
83
+ environment: 'dev',
84
+
85
+ rootDir: '.',
86
+
87
+ serviceProps: {
88
+ dockerFile: 'Dockerfile',
89
+ architecture: Cdk.aws_ecs.CpuArchitecture.ARM64,
90
+ cpu: 256, // 0.25 vCPU
91
+ memorySize: 512, // 512 MB
92
+ port: 3000,
93
+ desiredCount: 1,
94
+ healthCheckPath: '/health',
95
+ },
96
+ };
97
+
98
+ new Fargate(
99
+ new Cdk.App(),
100
+ `${config.application}-${config.service}-${config.environment}-stack`,
101
+ config
102
+ );
103
+ ```
104
+
105
+ ## Deploy
106
+
107
+ ```bash
108
+ npx cdk deploy --app "npx tsx stack/dev.ts" --profile default
109
+ ```
110
+
111
+ CDK builds your Docker image, pushes it to ECR, and deploys the service. The ALB DNS name is output:
112
+
113
+ ```
114
+ Outputs:
115
+ myapp-api-dev-stack.LoadBalancerDNS = myapp-api-dev-1234567890.us-east-1.elb.amazonaws.com
116
+ ```
117
+
118
+ ## Custom Domain with HTTPS (Optional)
119
+
120
+ 1. [Create a Route53 Hosted Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html)
121
+ 2. [Request an ACM certificate](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html) in the **same region as your service**
122
+
123
+ ```typescript
124
+ const config: FargateProps = {
125
+ // ...
126
+ domain: 'api.example.com',
127
+ regionalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123',
128
+ hostedZoneId: 'Z1234567890ABC',
129
+ };
130
+ ```
131
+
132
+ When a domain is configured:
133
+ - HTTPS listener is added on port 443
134
+ - HTTP on port 80 redirects to HTTPS
135
+ - Route53 A record is created pointing to the ALB
136
+
137
+ ## Environment Variables
138
+
139
+ ```typescript
140
+ serviceProps: {
141
+ // ...
142
+ variables: [
143
+ { NODE_ENV: 'production' },
144
+ { PORT: '3000' },
145
+ ],
146
+ },
147
+ ```
148
+
149
+ ## Secrets from AWS Secrets Manager
150
+
151
+ ```bash
152
+ aws secretsmanager create-secret \
153
+ --name "/myapp/DATABASE_URL" \
154
+ --secret-string "postgres://user:pass@host/db"
155
+ ```
156
+
157
+ ```typescript
158
+ serviceProps: {
159
+ // ...
160
+ secrets: [
161
+ { key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:/myapp/DATABASE_URL-abc123' },
162
+ ],
163
+ },
164
+ ```
165
+
166
+ Secrets are injected as environment variables at container startup. The task role is automatically granted read access.
167
+
168
+ ## Health Check
169
+
170
+ The ALB and ECS both perform health checks. By default they hit `/`. Configure a dedicated health endpoint:
171
+
172
+ ```typescript
173
+ serviceProps: {
174
+ healthCheckPath: '/health',
175
+ },
176
+ ```
177
+
178
+ Your app should return `200 OK` on that path within 5 seconds.
179
+
180
+ ## CPU & Memory Sizing
181
+
182
+ Fargate uses [fixed CPU/memory combinations](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/task-cpu-memory-error.html):
183
+
184
+ | CPU (units) | vCPU | Valid Memory (MB) |
185
+ |---|---|---|
186
+ | 256 | 0.25 | 512, 1024, 2048 |
187
+ | 512 | 0.5 | 1024–4096 |
188
+ | 1024 | 1 | 2048–8192 |
189
+ | 2048 | 2 | 4096–16384 |
190
+ | 4096 | 4 | 8192–30720 |
191
+
192
+ ## Estimated Cost
193
+
194
+ A minimal deployment (1 task, `us-east-1`, no free tier):
195
+
196
+ | Component | Monthly |
197
+ |---|---|
198
+ | Fargate (1 task, 0.25 vCPU / 512 MB) | ~$9 |
199
+ | Application Load Balancer | ~$22 |
200
+ | CloudWatch Logs | <$1 |
201
+ | Route53 | $0.50 |
202
+ | **Total** | **~$33/month** |
203
+
204
+ See [Fargate pricing](https://aws.amazon.com/fargate/pricing/) and [ALB pricing](https://aws.amazon.com/elasticloadbalancing/pricing/).
205
+
206
+ ## Stack Outputs
207
+
208
+ | Output | Description |
209
+ |---|---|
210
+ | `LoadBalancerDNS` | ALB DNS name |
211
+ | `Route53Domain` | Custom domain URL (only if domain is configured) |
212
+
213
+ ## Destroy
214
+
215
+ ```bash
216
+ npx cdk destroy --app "npx tsx stack/dev.ts" --profile default
217
+ ```
218
+
219
+ ## Next Steps
220
+
221
+ - [fargate-nixpacks.md](./fargate-nixpacks.md) - Auto-generate Dockerfiles with Nixpacks
222
+ - [fargate-full.md](./fargate-full.md) - Full configuration reference