@thunder-so/thunder 1.1.0 → 1.3.0

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.
package/README.md CHANGED
@@ -342,6 +342,256 @@ new Astro(new Cdk.App(), 'myapp-web-prod-stack', config);
342
342
 
343
343
  ---
344
344
 
345
+ ### Serverless Frameworks
346
+
347
+ Deploy modern meta-frameworks as serverless applications with unified infrastructure - Lambda for server-side rendering and S3 for static assets, all behind CloudFront.
348
+
349
+ **Best for:** Full-stack applications with server-side rendering, API routes, and static asset optimization
350
+
351
+ **AWS Resources:**
352
+ - [Lambda Function](https://aws.amazon.com/lambda/) - SSR server with container support
353
+ - [S3 Bucket](https://aws.amazon.com/s3/) - Static assets with OAC
354
+ - [CloudFront Distribution](https://aws.amazon.com/cloudfront/) - Global CDN with custom domain
355
+ - [API Gateway](https://aws.amazon.com/api-gateway/) - HTTP API for server functions
356
+ - [Route53](https://aws.amazon.com/route53/) - DNS management (optional)
357
+ - [ACM](https://aws.amazon.com/certificate-manager/) - SSL certificates (optional)
358
+
359
+ **Supported Frameworks:**
360
+ - [TanStack Start](https://tanstack.com/start) - Type-safe full-stack React framework
361
+ - [Nuxt](https://nuxt.com/) - Vue-based full-stack framework
362
+ - [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
+ - [SvelteKit](https://kit.svelte.dev/) - Svelte-based full-stack framework
365
+ - [Solid Start](https://start.solidjs.com/) - SolidJS full-stack framework
366
+ - [AnalogJS](https://analogjs.org/) - Angular-based full-stack framework
367
+
368
+ #### TanStack Start
369
+
370
+ **Example:**
371
+ ```typescript
372
+ import { Cdk, TanStackStart, type TanStackStartProps } from '@thunder-so/thunder';
373
+
374
+ const config: TanStackStartProps = {
375
+ env: { account: '123456789012', region: 'us-east-1' },
376
+ application: 'myapp',
377
+ service: 'web',
378
+ environment: 'prod',
379
+ rootDir: '.',
380
+
381
+ serverProps: {
382
+ runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
383
+ architecture: Cdk.aws_lambda.Architecture.ARM_64,
384
+ memorySize: 1792,
385
+ timeout: 10,
386
+ keepWarm: true,
387
+ variables: [{ NODE_ENV: 'production' }],
388
+ },
389
+
390
+ // Optional: Custom domain
391
+ domain: 'myapp.com',
392
+ globalCertificateArn: 'arn:aws:acm:us-east-1:...',
393
+ hostedZoneId: 'Z123456789',
394
+ };
395
+
396
+ new TanStackStart(new Cdk.App(), 'myapp-web-prod-stack', config);
397
+ ```
398
+
399
+ #### Nuxt
400
+
401
+ **Example:**
402
+ ```typescript
403
+ import { Cdk, Nuxt, type NuxtProps } from '@thunder-so/thunder';
404
+
405
+ const config: NuxtProps = {
406
+ env: { account: '123456789012', region: 'us-east-1' },
407
+ application: 'myapp',
408
+ service: 'web',
409
+ environment: 'prod',
410
+ rootDir: '.',
411
+
412
+ serverProps: {
413
+ runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
414
+ architecture: Cdk.aws_lambda.Architecture.ARM_64,
415
+ memorySize: 1792,
416
+ timeout: 10,
417
+ keepWarm: true,
418
+ streaming: true,
419
+ variables: [{ NODE_ENV: 'production' }],
420
+ secrets: [{ key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:...' }],
421
+ },
422
+
423
+ // Optional: Custom domain
424
+ domain: 'myapp.com',
425
+ globalCertificateArn: 'arn:aws:acm:us-east-1:...',
426
+ hostedZoneId: 'Z123456789',
427
+ };
428
+
429
+ new Nuxt(new Cdk.App(), 'myapp-web-prod-stack', config);
430
+ ```
431
+
432
+ #### Astro
433
+
434
+ **Example:**
435
+ ```typescript
436
+ import { Cdk, Astro, type AstroProps } from '@thunder-so/thunder';
437
+
438
+ const config: AstroProps = {
439
+ env: { account: '123456789012', region: 'us-east-1' },
440
+ application: 'myapp',
441
+ service: 'web',
442
+ environment: 'prod',
443
+ rootDir: '.',
444
+
445
+ serverProps: {
446
+ runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
447
+ architecture: Cdk.aws_lambda.Architecture.ARM_64,
448
+ memorySize: 1024,
449
+ timeout: 10,
450
+ keepWarm: true,
451
+ variables: [{ NODE_ENV: 'production' }],
452
+ },
453
+
454
+ // Optional: Custom domain
455
+ domain: 'myapp.com',
456
+ globalCertificateArn: 'arn:aws:acm:us-east-1:...',
457
+ hostedZoneId: 'Z123456789',
458
+ };
459
+
460
+ new Astro(new Cdk.App(), 'myapp-web-prod-stack', config);
461
+ ```
462
+
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
+ #### SvelteKit
501
+
502
+ **Example:**
503
+ ```typescript
504
+ import { Cdk, SvelteKit, type SvelteKitProps } from '@thunder-so/thunder';
505
+
506
+ const config: SvelteKitProps = {
507
+ env: { account: '123456789012', region: 'us-east-1' },
508
+ application: 'myapp',
509
+ service: 'web',
510
+ environment: 'prod',
511
+ rootDir: '.',
512
+
513
+ serverProps: {
514
+ runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
515
+ architecture: Cdk.aws_lambda.Architecture.ARM_64,
516
+ memorySize: 1024,
517
+ timeout: 10,
518
+ keepWarm: true,
519
+ variables: [{ NODE_ENV: 'production' }],
520
+ },
521
+
522
+ // Optional: Custom domain
523
+ domain: 'myapp.com',
524
+ globalCertificateArn: 'arn:aws:acm:us-east-1:...',
525
+ hostedZoneId: 'Z123456789',
526
+ };
527
+
528
+ new SvelteKit(new Cdk.App(), 'myapp-web-prod-stack', config);
529
+ ```
530
+
531
+ #### Solid Start
532
+
533
+ **Example:**
534
+ ```typescript
535
+ import { Cdk, SolidStart, type SolidStartProps } from '@thunder-so/thunder';
536
+
537
+ const config: SolidStartProps = {
538
+ env: { account: '123456789012', region: 'us-east-1' },
539
+ application: 'myapp',
540
+ service: 'web',
541
+ environment: 'prod',
542
+ rootDir: '.',
543
+
544
+ serverProps: {
545
+ runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
546
+ architecture: Cdk.aws_lambda.Architecture.ARM_64,
547
+ memorySize: 1024,
548
+ timeout: 10,
549
+ keepWarm: true,
550
+ variables: [{ NODE_ENV: 'production' }],
551
+ },
552
+
553
+ // Optional: Custom domain
554
+ domain: 'myapp.com',
555
+ globalCertificateArn: 'arn:aws:acm:us-east-1:...',
556
+ hostedZoneId: 'Z123456789',
557
+ };
558
+
559
+ new SolidStart(new Cdk.App(), 'myapp-web-prod-stack', config);
560
+ ```
561
+
562
+ #### AnalogJS
563
+
564
+ **Example:**
565
+ ```typescript
566
+ import { Cdk, AnalogJS, type AnalogJSProps } from '@thunder-so/thunder';
567
+
568
+ const config: AnalogJSProps = {
569
+ env: { account: '123456789012', region: 'us-east-1' },
570
+ application: 'myapp',
571
+ service: 'web',
572
+ environment: 'prod',
573
+ rootDir: '.',
574
+
575
+ serverProps: {
576
+ runtime: Cdk.aws_lambda.Runtime.NODEJS_22_X,
577
+ architecture: Cdk.aws_lambda.Architecture.ARM_64,
578
+ memorySize: 1024,
579
+ timeout: 10,
580
+ keepWarm: true,
581
+ variables: [{ NODE_ENV: 'production' }],
582
+ },
583
+
584
+ // Optional: Custom domain
585
+ domain: 'myapp.com',
586
+ globalCertificateArn: 'arn:aws:acm:us-east-1:...',
587
+ hostedZoneId: 'Z123456789',
588
+ };
589
+
590
+ new AnalogJS(new Cdk.App(), 'myapp-web-prod-stack', config);
591
+ ```
592
+
593
+ ---
594
+
345
595
  ### Template
346
596
 
347
597
  Deploy [Coolify](https://coolify.io/)-style templates on EC2. Automatically fetches and hydrates Docker Compose templates from the [Coolify templates repository](https://github.com/coollabsio/coolify).
package/index.ts CHANGED
@@ -4,9 +4,11 @@ export { Lambda } from './stacks/LambdaStack';
4
4
  export { Fargate } from './stacks/FargateStack';
5
5
  export { Ec2 } from './stacks/Ec2Stack';
6
6
  export { Template } from './stacks/TemplateStack';
7
- export { Nuxt } from './stacks/NuxtStack';
8
- export { Astro } from './stacks/AstroStack';
9
7
  export { Vpc } from './stacks/VpcStack';
8
+ export { ServerlessStack } from './stacks/ServerlessStack';
9
+
10
+ // Serverless framework stacks (new unified abstraction)
11
+ export * from './lib/serverless';
10
12
 
11
13
  // Types
12
14
  export type { StaticProps } from './types/StaticProps';
@@ -14,10 +16,17 @@ export type { LambdaProps } from './types/LambdaProps';
14
16
  export type { FargateProps } from './types/FargateProps';
15
17
  export type { Ec2Props } from './types/Ec2Props';
16
18
  export type { TemplateProps } from './types/TemplateProps';
17
- export type { NuxtProps } from './types/NuxtProps';
18
- export type { NuxtProps as AstroProps } from './types/NuxtProps';
19
19
 
20
- // Template utilities
20
+ // Serverless framework types
21
+ export type { ServerlessBaseProps as NuxtProps } from './types/ServerlessProps';
22
+ export type { ServerlessBaseProps as AstroProps } from './types/ServerlessProps';
23
+ export type { ServerlessBaseProps as TanStackStartProps } from './types/ServerlessProps';
24
+ export type { ServerlessBaseProps as SvelteKitProps } from './types/ServerlessProps';
25
+ export type { ServerlessBaseProps as SolidStartProps } from './types/ServerlessProps';
26
+ export type { ServerlessBaseProps as AnalogJSProps } from './types/ServerlessProps';
27
+ export type { ServerlessBaseProps, ServerlessServerProps, ServerlessClientProps } from './types/ServerlessProps';
28
+
29
+ // Coolify Template utilities
21
30
  export { fetchTemplate } from './lib/template/template/fetch';
22
31
  export { hydrateTemplate } from './lib/template/template/hydrate';
23
32
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thunder-so/thunder",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "CDK library for deploying web applications on AWS",
5
5
  "keywords": [
6
6
  "aws",
package/.agents/CLI.md DELETED
@@ -1,65 +0,0 @@
1
- # Thunder CLI Scope
2
-
3
- The Thunder CLI (`th`) is the primary interface for developing, deploying, and managing applications built with `@thunder-so/thunder`. It is designed to be a thin, context-aware wrapper around the AWS CDK, providing a developer experience similar to SST but tailored for the Thunder ecosystem.
4
-
5
- ## Core Mandates
6
-
7
- 1. **Context-Awareness:** [x] **DONE**: The CLI automatically detects the current environment, application, and service from the repository structure or configuration, minimizing repetitive flag usage.
8
- 2. **Zero-Config Defaults:** [x] **DONE**: "It just works" out of the box with sensible defaults for AWS regions, accounts, and resource sizing.
9
- 3. **Local Dev Parity:** [ ] **TODO**: Enables a local development loop that closely mirrors production, including live Lambda iteration (future scope) and local emulation of static sites.
10
-
11
- ## Command Reference
12
-
13
- ### `th init`
14
- - [ ] **TODO**: Scaffolds a new Thunder project or adds a new service to an existing monorepo.
15
-
16
- - **Usage:** `th init [template] [name]`
17
- - **Features:**
18
- - Detects if running in an existing workspace (monorepo).
19
- - Prompts for project type: `static`, `lambda`, `fargate`, `nuxt`, `astro`, `ec2`, `template`.
20
- - Generates `thunder.config.ts` (or updates it).
21
- - Creates necessary `bin/*.ts` entry points.
22
- - Sets up `.gitignore` and `package.json` scripts.
23
-
24
- ### `th deploy`
25
- - [ ] **TODO**: Deploys the application to AWS.
26
-
27
- - **Usage:** `th deploy [--stage <stage>] [--filter <service>]`
28
- - **Features:**
29
- - **Stage Management:** defaults to `dev` for local, but supports `prod`, `staging`, `pr-*`.
30
- - **Context-Driven:** [x] **DONE**: Reads `bin/*.ts` files to determine which stacks to deploy.
31
- - **Metadata Push:** [x] **DONE**: Updates the `thunder-discovery` bucket with new resource ARNs and endpoints after successful deployment.
32
- - **Output:** Prints critical URLs (CloudFront, API Gateway, ALB) to the console.
33
-
34
- ### `th destroy`
35
- - [ ] **TODO**: Tears down resources.
36
-
37
- - **Usage:** `th remove [--stage <stage>] [--filter <service>]`
38
- - **Features:**
39
- - **Safety Checks:** Prompts for confirmation, especially for `prod` stages or stateful resources (RDS, S3).
40
- - **Metadata Cleanup:** Removes entries from the `thunder-discovery` bucket.
41
-
42
- ## Implementation Details
43
-
44
- ### Context Resolution (`bin/*.ts`)
45
- - [x] **DONE**: The CLI relies on the convention of `bin/<type>.ts` files.
46
- - `th deploy` scans `bin/` directory.
47
- - It executes these scripts using `ts-node` or `tsx`.
48
- - The scripts instantiate the Stacks (e.g., `NuxtStack`, `FargateStack`).
49
- - The CLI injects context (app, env, service, account, region) via environment variables or context context keys.
50
-
51
- ### CLI Architecture
52
- - [ ] **TODO**:
53
- - **Runtime:** Node.js
54
- - **Core Libs:** `aws-cdk` (programmatic), `aws-sdk` (v3), `inquirer` (prompts), `commander` (args), `ink` (TUI).
55
- - **Build:** `esbuild` for fast bundling of Lambda code during `th dev`.
56
-
57
- ## Comparison with SST
58
-
59
- | Feature | SST CLI | Thunder CLI |
60
- | :--- | :--- | :--- |
61
- | **Engine** | Pulumi / Terraform (v3) | AWS CDK (Native) |
62
- | **Language** | TypeScript / Python / Go | TypeScript (Strict) |
63
- | **State** | Cloud State Backend | CloudFormation + S3 Metadata |
64
- | **Local Dev** | Live Lambda (Multiplexing) | Hotswap + Local Framework Server |
65
- | **Constructs** | Broad (150+ providers) | Focused (AWS Web patterns) |
@@ -1,75 +0,0 @@
1
- # Metadata Discovery
2
-
3
- Thunder implements an "SST-style" discovery mechanism to enable the Thunder CLI and potential future Thunder Console to automatically identify and interact with deployed resources without relying on manual tagging or complex CloudFormation stack queries.
4
-
5
- ## How Thunder Tags Deployments
6
-
7
- - [x] **DONE**: Thunder uses a state-based approach rather than traditional AWS resource tags for discovery.
8
-
9
- ### State Storage
10
- When you deploy a Thunder service, it automatically stores its deployment state in a centralized S3 bucket named `thunder-discovery-<account>-<region>`.
11
-
12
- ### Key Structure
13
- Metadata files are stored with the following hierarchy:
14
- `apps/<application>/<environment>/<service>/metadata.json`
15
-
16
- ### Metadata Content
17
- The `metadata.json` file contains a standardized set of properties that align with the service's `CfnOutput` names:
18
- ```json
19
- {
20
- "id": "myapp-prod-web",
21
- "application": "myapp",
22
- "service": "web",
23
- "environment": "prod",
24
- "region": "us-east-1",
25
- "timestamp": "2026-03-04T12:00:00.000Z",
26
- "type": "Nuxt",
27
- "DistributionId": "E1234567890",
28
- "DistributionUrl": "https://d123.cloudfront.net",
29
- "Route53Domain": "https://myapp.com",
30
- "CodePipelineName": "myapp-prod-web-pipeline"
31
- }
32
- ```
33
-
34
- ## How the CLI/Console Discovers Apps
35
-
36
- 1. **Bucket Resolution**: The tool determines the discovery bucket name based on the current AWS account and region.
37
- 2. **S3 Scanning**: It lists the objects in the bucket under the `apps/` prefix.
38
- 3. **Metadata Parsing**: It reads the `metadata.json` files to discover:
39
- - All deployed Thunder apps.
40
- - Their environments/stages.
41
- - Their individual services and associated resource IDs/URLs.
42
- 4. **Automatic Discovery**: Because the `DiscoveryConstruct` is embedded in every Thunder stack, new services and updates are automatically reflected in S3 upon successful deployment.
43
-
44
- ## Implementation Details
45
-
46
- - [x] **DONE**: **`DiscoveryConstruct`**: A shared construct located in `lib/constructs/discovery.ts`.
47
- - [x] **DONE**: **`BucketDeployment`**: Uses `aws-s3-deployment` to upload `Source.jsonData` during the CDK deployment phase.
48
- - [x] **DONE**: **Standardization**: Metadata field names are strictly aligned with `CfnOutput` logical IDs (e.g., `DistributionId`, `ServiceUrl`).
49
- - [x] **DONE**: Each deployment stores its metadata in a centralized S3 bucket (`thunder-discovery-<account>-<region>`).
50
-
51
- Metadata includes:
52
- - [x] App identity (application, service, environment)
53
- - [x] Resource ARNs, IDs and URLs (Aligned with `CfnOutput` names)
54
- - [x] Deployment timestamps
55
- - [x] Framework-specific metadata
56
- - [x] Route53 domain integration
57
-
58
-
59
- ## ISSUES:
60
-
61
- 7:11:10 PM | CREATE_FAILED | Custom::CDKBucketDeployment | Discovery/StoreMet...omResource/Default
62
- Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'sync', '/tmp/tmpxgahyp87/contents', 's3://thunder-discovery-047719662375-us-east
63
- -1/apps/nuxt3/dev/fargate']' returned non-zero exit status 1. (RequestId: afc6bb52-d373-4b97-9a7d-36d0ab9b9425)
64
- 7:11:10 PM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | nuxt3-fargate-dev-stack
65
- The following resource(s) failed to create: [DiscoveryStoreMetadataCustomResource5F6695DB, FargateFargateService7449B65B]. Rollback requested by user.
66
- 7:11:10 PM | ROLLBACK_IN_PROGRESS | AWS::CloudFormation::Stack | nuxt3-fargate-dev-stack
67
- The following resource(s) failed to create: [DiscoveryStoreMetadataCustomResource5F6695DB, FargateFargateService7449B65B]. Rollback requested by user.
68
- 7:11:37 PM | DELETE_FAILED | Custom::CDKBucketDeployment | Discovery/StoreMet...omResource/Default
69
- Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'rm', 's3://thunder-discovery-047719662375-us-east-1/apps/nuxt3/dev/fargate', '--
70
- recursive']' returned non-zero exit status 1. (RequestId: f9383113-0976-4fe3-af60-bcefbf14d514)
71
-
72
- ❌ nuxt3-fargate-dev-stack failed: ToolkitError: The stack named nuxt3-fargate-dev-stack failed creation, it may need to be manually deleted from the AWS console: ROLLBACK_FAILED (The following resource(s) failed to delete: [DiscoveryStoreMetadataCustomResource5F6695DB]. ): Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'sync', '/tmp/tmpxgahyp87/contents', 's3://thunder-discovery-047719662375-us-east-1/apps/nuxt3/dev/fargate']' returned non-zero exit status 1. (RequestId: afc6bb52-d373-4b97-9a7d-36d0ab9b9425), Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'rm', 's3://thunder-discovery-047719662375-us-east-1/apps/nuxt3/dev/fargate', '--recursive']' returned non-zero exit status 1. (RequestId: f9383113-0976-4fe3-af60-bcefbf14d514)
73
-
74
- The following resource(s) failed to delete: [DiscoveryStoreMetadataCustomResource5F6695DB].
75
- Received response status [FAILED] from custom resource. Message returned: Command '['/opt/awscli/aws', 's3', 'rm', 's3://thunder-discovery-047719662375-us-east-1/apps/nuxt3/dev/fargate', '--recursive']' returned non-zero exit status 1. (RequestId: f9383113-0976-4fe3-af60-bcefbf14d514)