@thunder-so/thunder 1.3.1 → 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,145 @@
1
+ # Static Hosting Configuration Reference
2
+
3
+ Complete reference for every option available in the `Static` construct. Covers S3, CloudFront, Lambda@Edge, custom domains, and cache behavior. For a quick start see [static-basic.md](./static-basic.md).
4
+
5
+ ## Full Example
6
+
7
+ ```typescript
8
+ import { Cdk, Static, type StaticProps } from '@thunder-so/thunder';
9
+
10
+ const config: StaticProps = {
11
+ // Identity
12
+ env: {
13
+ account: '123456789012',
14
+ region: 'us-east-1',
15
+ },
16
+ application: 'myapp',
17
+ service: 'web',
18
+ environment: 'prod',
19
+
20
+ // Source
21
+ rootDir: '.', // monorepo: e.g. 'apps/web'
22
+ outputDir: 'dist', // build output folder
23
+
24
+ // Custom Domain
25
+ domain: 'app.example.com',
26
+ globalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123',
27
+ hostedZoneId: 'Z1234567890ABC',
28
+
29
+ // CloudFront Behavior
30
+ errorPagePath: '/404.html',
31
+ allowHeaders: ['Accept-Language'],
32
+ allowCookies: ['session-*'],
33
+ allowQueryParams: ['lang', 'theme'],
34
+ // denyQueryParams: ['utm_source', 'fbclid'], // mutually exclusive with allowQueryParams
35
+
36
+ // Lambda@Edge
37
+ redirects: [
38
+ { source: '/old', destination: '/new' },
39
+ { source: '/blog/:year/:month', destination: '/posts/:year/:month' },
40
+ ],
41
+ rewrites: [
42
+ { source: '/app/*', destination: '/index.html' },
43
+ ],
44
+ headers: [
45
+ { path: '/assets/*', name: 'Cache-Control', value: 'public, max-age=31536000, immutable' },
46
+ { path: '/**', name: 'X-Frame-Options', value: 'SAMEORIGIN' },
47
+ ],
48
+
49
+ // Debug
50
+ debug: false,
51
+ };
52
+
53
+ new Static(new Cdk.App(), 'myapp-web-prod-stack', config);
54
+ ```
55
+
56
+ ## Property Reference
57
+
58
+ ### Identity (`AppProps`)
59
+
60
+ | Property | Type | Required | Default | Description |
61
+ |---|---|---|---|---|
62
+ | `env.account` | `string` | Yes | - | AWS account ID |
63
+ | `env.region` | `string` | Yes | - | AWS region |
64
+ | `application` | `string` | Yes | - | Project name, used in resource naming |
65
+ | `service` | `string` | Yes | - | Service name, used in resource naming |
66
+ | `environment` | `string` | Yes | - | Environment label, e.g. `prod`, `dev` |
67
+ | `rootDir` | `string` | No | `.` | Root of your app. Supports monorepos |
68
+ | `contextDirectory` | `string` | No | - | CDK context directory override |
69
+ | `debug` | `boolean` | No | `false` | Enables S3 access logs and CloudFront logging |
70
+
71
+ ### Source
72
+
73
+ | Property | Type | Required | Default | Description |
74
+ |---|---|---|---|---|
75
+ | `outputDir` | `string` | No | `dist` | Build output directory, relative to `rootDir` |
76
+
77
+ ### Custom Domain (`DomainProps`)
78
+
79
+ | Property | Type | Description |
80
+ |---|---|---|
81
+ | `domain` | `string` | Public domain, e.g. `app.example.com` |
82
+ | `globalCertificateArn` | `string` | ACM certificate ARN - **must be in `us-east-1`** |
83
+ | `hostedZoneId` | `string` | Route53 hosted zone ID |
84
+
85
+ All three must be provided together for DNS to be configured.
86
+
87
+ ### CloudFront (`CloudFrontProps`)
88
+
89
+ | Property | Type | Default | Description |
90
+ |---|---|---|---|
91
+ | `errorPagePath` | `string` | `/index.html` | Path served for 404 errors |
92
+ | `allowHeaders` | `string[]` | `[]` | Headers forwarded to origin and included in cache key |
93
+ | `allowCookies` | `string[]` | `[]` | Cookies forwarded to origin and included in cache key |
94
+ | `allowQueryParams` | `string[]` | `[]` | Query params included in cache key |
95
+ | `denyQueryParams` | `string[]` | `[]` | Query params stripped from cache key. Ignored if `allowQueryParams` is set |
96
+
97
+ ### Lambda@Edge (`EdgeProps`)
98
+
99
+ | Property | Type | Description |
100
+ |---|---|---|
101
+ | `redirects` | `{ source: string; destination: string }[]` | 301 redirects. Supports wildcards (`*`) and placeholders (`:name`) |
102
+ | `rewrites` | `{ source: string; destination: string }[]` | Internal path rewrites. Same pattern syntax as redirects |
103
+ | `headers` | `{ path: string; name: string; value: string }[]` | Custom response headers per path pattern |
104
+
105
+ See [static-edge-functions.md](./static-edge-functions.md) for pattern syntax and examples.
106
+
107
+ ## CloudFront Distribution Details
108
+
109
+ - **Protocol:** HTTP/3 with HTTP/2 fallback
110
+ - **TLS:** Minimum TLS 1.2 (2021 security policy)
111
+ - **Compression:** Brotli and Gzip enabled
112
+ - **Default cache TTL:** 1 minute for HTML, optimized long-term caching for static assets (`*.js`, `*.css`, `*.png`, etc.)
113
+ - **Static asset patterns** (`*.js`, `*.css`, `*.png`, `*.jpg`, `*.jpeg`, `*.gif`, `*.ico`) use `CachePolicy.CACHING_OPTIMIZED` with CORS headers
114
+ - **OAC:** S3 bucket is fully private; CloudFront accesses it via SigV4-signed Origin Access Control
115
+
116
+ ## S3 Bucket Details
117
+
118
+ - Versioning enabled
119
+ - Server-side encryption (S3-managed)
120
+ - All public access blocked
121
+ - `RemovalPolicy.RETAIN` - the bucket is **not** deleted when the stack is destroyed
122
+
123
+ ## Stack Outputs
124
+
125
+ | Output | Description |
126
+ |---|---|
127
+ | `DistributionId` | CloudFront distribution ID |
128
+ | `DistributionUrl` | CloudFront distribution URL (`https://xxxx.cloudfront.net`) |
129
+ | `Route53Domain` | Custom domain URL (only if `domain` is set) |
130
+
131
+ ## Supported Frameworks
132
+
133
+ Any framework that produces a static output directory works:
134
+
135
+ | Framework | Output Dir | Notes |
136
+ |---|---|---|
137
+ | [Vite](https://vite.dev/) (React, Vue, Svelte, Solid) | `dist` | Default |
138
+ | [Next.js](https://nextjs.org/docs/app/building-your-application/deploying/static-exports) | `out` | Requires `output: 'export'` in `next.config.js` |
139
+ | [Astro](https://docs.astro.build/en/guides/deploy/) | `dist` | SSG mode (`output: 'static'`) |
140
+ | [Gatsby](https://www.gatsbyjs.com/) | `public` | - |
141
+
142
+ ## Related
143
+
144
+ - [static-basic.md](./static-basic.md) - Quick start
145
+ - [static-edge-functions.md](./static-edge-functions.md) - Redirects, rewrites, and custom headers
package/index.ts CHANGED
@@ -5,10 +5,10 @@ export { Fargate } from './stacks/FargateStack';
5
5
  export { Ec2 } from './stacks/Ec2Stack';
6
6
  export { Template } from './stacks/TemplateStack';
7
7
  export { Vpc } from './stacks/VpcStack';
8
- export { ServerlessStack } from './stacks/ServerlessStack';
9
8
 
10
9
  // Serverless framework stacks (new unified abstraction)
11
10
  export * from './lib/serverless';
11
+ export { ServerlessStack as Serverless } from './stacks/ServerlessStack';
12
12
 
13
13
  // Types
14
14
  export type { StaticProps } from './types/StaticProps';
@@ -18,13 +18,13 @@ export type { Ec2Props } from './types/Ec2Props';
18
18
  export type { TemplateProps } from './types/TemplateProps';
19
19
 
20
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';
21
+ export type { ServerlessProps as NuxtProps } from './types/ServerlessProps';
22
+ export type { ServerlessProps as AstroProps } from './types/ServerlessProps';
23
+ export type { ServerlessProps as TanStackStartProps } from './types/ServerlessProps';
24
+ export type { ServerlessProps as SvelteKitProps } from './types/ServerlessProps';
25
+ export type { ServerlessProps as SolidStartProps } from './types/ServerlessProps';
26
+ export type { ServerlessProps as AnalogJSProps } from './types/ServerlessProps';
27
+ export type { ServerlessProps, ServerlessServerProps, ServerlessClientProps } from './types/ServerlessProps';
28
28
 
29
29
  // Coolify Template utilities
30
30
  export { fetchTemplate } from './lib/template/template/fetch';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thunder-so/thunder",
3
- "version": "1.3.1",
3
+ "version": "1.3.2",
4
4
  "description": "CDK library for deploying web applications on AWS",
5
5
  "keywords": [
6
6
  "aws",