@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.
- package/.kiro/settings/lsp.json +198 -0
- package/README.md +60 -118
- package/docs/fargate-basic.md +222 -0
- package/docs/fargate-full.md +177 -0
- package/docs/fargate-nixpacks.md +199 -0
- package/docs/frameworks/analogjs-fargate.md +115 -0
- package/docs/frameworks/analogjs-serverless.md +121 -0
- package/docs/frameworks/astro-fargate.md +120 -0
- package/docs/frameworks/astro-serverless.md +112 -0
- package/docs/frameworks/astro-static.md +108 -0
- package/docs/frameworks/nextjs-fargate-dockerfile.md +227 -0
- package/docs/frameworks/nextjs-fargate-nixpacks.md +113 -0
- package/docs/frameworks/nextjs-static.md +160 -0
- package/docs/frameworks/nuxt-fargate.md +115 -0
- package/docs/frameworks/nuxt-serverless.md +122 -0
- package/docs/frameworks/solidstart-fargate.md +115 -0
- package/docs/frameworks/solidstart-serverless.md +116 -0
- package/docs/frameworks/sveltekit-fargate.md +130 -0
- package/docs/frameworks/sveltekit-serverless.md +120 -0
- package/docs/frameworks/tanstack-start-fargate.md +115 -0
- package/docs/frameworks/tanstack-start-serverless.md +205 -0
- package/docs/lambda-basic.md +178 -0
- package/docs/lambda-containers.md +179 -0
- package/docs/lambda-full.md +185 -0
- package/docs/serverless.md +267 -0
- package/docs/static-basic.md +151 -0
- package/docs/static-edge-functions.md +187 -0
- package/docs/static-full.md +145 -0
- package/index.ts +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Deploy Next.js Static Export to AWS S3 + CloudFront
|
|
2
|
+
|
|
3
|
+
Host your Next.js app as a static site on AWS using Thunder's `Static` construct. This guide covers static export mode - no server required, just HTML, CSS, and JavaScript served from [S3](https://aws.amazon.com/s3/) through [CloudFront](https://aws.amazon.com/cloudfront/).
|
|
4
|
+
|
|
5
|
+
Perfect for marketing sites, blogs, documentation, and SPAs that don't need server-side rendering.
|
|
6
|
+
|
|
7
|
+
## 1. Create a New Next.js Project
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bunx create-next-app@latest my-nextjs-app
|
|
11
|
+
cd my-nextjs-app
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
When prompted:
|
|
15
|
+
- TypeScript: Yes
|
|
16
|
+
- ESLint: Yes
|
|
17
|
+
- Tailwind CSS: Yes (optional)
|
|
18
|
+
- `src/` directory: No (optional)
|
|
19
|
+
- App Router: Yes
|
|
20
|
+
- Turbopack: Yes (optional)
|
|
21
|
+
- Import alias: `@/*` (default)
|
|
22
|
+
|
|
23
|
+
Reference: [Next.js Installation Docs](https://nextjs.org/docs/getting-started/installation)
|
|
24
|
+
|
|
25
|
+
## 2. Configure Static Export
|
|
26
|
+
|
|
27
|
+
Edit `next.config.ts`:
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import type { NextConfig } from 'next';
|
|
31
|
+
|
|
32
|
+
const nextConfig: NextConfig = {
|
|
33
|
+
output: 'export',
|
|
34
|
+
// Optional: change output directory from 'out' to 'dist'
|
|
35
|
+
distDir: 'dist',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export default nextConfig;
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Reference: [Next.js Static Exports](https://nextjs.org/docs/app/guides/static-exports)
|
|
42
|
+
|
|
43
|
+
## 3. Build Your App
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
bun run build
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
This generates static files in the `dist/` directory (or `out/` if you didn't set `distDir`).
|
|
50
|
+
|
|
51
|
+
## 4. Install Thunder
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
bun add @thunder-so/thunder --development
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 5. Create Stack File
|
|
58
|
+
|
|
59
|
+
Create `stack/prod.ts`:
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { Cdk, Static, type StaticProps } from '@thunder-so/thunder';
|
|
63
|
+
|
|
64
|
+
const config: StaticProps = {
|
|
65
|
+
env: {
|
|
66
|
+
account: '123456789012', // Your AWS account ID
|
|
67
|
+
region: 'us-east-1',
|
|
68
|
+
},
|
|
69
|
+
application: 'myapp',
|
|
70
|
+
service: 'web',
|
|
71
|
+
environment: 'prod',
|
|
72
|
+
|
|
73
|
+
rootDir: '.',
|
|
74
|
+
outputDir: 'dist', // Match your next.config.ts distDir
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
new Static(
|
|
78
|
+
new Cdk.App(),
|
|
79
|
+
`${config.application}-${config.service}-${config.environment}-stack`,
|
|
80
|
+
config
|
|
81
|
+
);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 6. Deploy
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
npx cdk deploy --app "npx tsx stack/prod.ts" --profile default
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
CDK outputs the CloudFront URL:
|
|
91
|
+
|
|
92
|
+
```
|
|
93
|
+
Outputs:
|
|
94
|
+
myapp-web-prod-stack.DistributionUrl = https://d1234abcd.cloudfront.net
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Custom Domain (Optional)
|
|
98
|
+
|
|
99
|
+
1. [Create a Route53 Hosted Zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html)
|
|
100
|
+
2. [Request an ACM certificate](https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html) in **`us-east-1`**
|
|
101
|
+
|
|
102
|
+
Update your stack:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const config: StaticProps = {
|
|
106
|
+
// ...
|
|
107
|
+
domain: 'app.example.com',
|
|
108
|
+
globalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123',
|
|
109
|
+
hostedZoneId: 'Z1234567890ABC',
|
|
110
|
+
};
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Redirects and Rewrites
|
|
114
|
+
|
|
115
|
+
Add URL redirects or rewrites using Lambda@Edge:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
const config: StaticProps = {
|
|
119
|
+
// ...
|
|
120
|
+
redirects: [
|
|
121
|
+
{ source: '/old-page', destination: '/new-page' },
|
|
122
|
+
],
|
|
123
|
+
rewrites: [
|
|
124
|
+
{ source: '/app/*', destination: '/index.html' }, // SPA fallback
|
|
125
|
+
],
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
See [static-edge-functions.md](../static-edge-functions.md) for pattern syntax.
|
|
130
|
+
|
|
131
|
+
## Custom Headers
|
|
132
|
+
|
|
133
|
+
Add security or cache headers:
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
const config: StaticProps = {
|
|
137
|
+
// ...
|
|
138
|
+
headers: [
|
|
139
|
+
{ path: '/assets/*', name: 'Cache-Control', value: 'public, max-age=31536000, immutable' },
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Limitations of Static Export
|
|
145
|
+
|
|
146
|
+
Next.js static export doesn't support:
|
|
147
|
+
- Server-side rendering (SSR)
|
|
148
|
+
- API routes
|
|
149
|
+
- Image optimization (use `unoptimized: true` in `next.config.ts`)
|
|
150
|
+
- Incremental Static Regeneration (ISR)
|
|
151
|
+
- Dynamic routes without `generateStaticParams`
|
|
152
|
+
|
|
153
|
+
For these features, use [Next.js on Fargate](./nextjs-fargate-dockerfile.md) instead.
|
|
154
|
+
|
|
155
|
+
## Related
|
|
156
|
+
|
|
157
|
+
- [static-basic.md](../static-basic.md) - Static construct reference
|
|
158
|
+
- [static-edge-functions.md](../static-edge-functions.md) - Redirects, rewrites, headers
|
|
159
|
+
- [static-full.md](../static-full.md) - Full configuration reference
|
|
160
|
+
- [nextjs-fargate-dockerfile.md](./nextjs-fargate-dockerfile.md) - Next.js with SSR on Fargate
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Deploy Nuxt to AWS Fargate
|
|
2
|
+
|
|
3
|
+
Run your Nuxt app with full SSR support on [AWS ECS Fargate](https://aws.amazon.com/fargate/) using Thunder's `Fargate` construct.
|
|
4
|
+
|
|
5
|
+
## 1. Create a New Nuxt Project
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx nuxi@latest init my-nuxt-app
|
|
9
|
+
cd my-nuxt-app
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Reference: [Nuxt Installation Docs](https://nuxt.com/docs/getting-started/installation)
|
|
13
|
+
|
|
14
|
+
## 2. Create Dockerfile
|
|
15
|
+
|
|
16
|
+
```dockerfile
|
|
17
|
+
FROM oven/bun:latest AS builder
|
|
18
|
+
WORKDIR /app
|
|
19
|
+
|
|
20
|
+
COPY package.json bun.lockb ./
|
|
21
|
+
RUN bun install --frozen-lockfile
|
|
22
|
+
|
|
23
|
+
COPY . .
|
|
24
|
+
RUN bun run build
|
|
25
|
+
|
|
26
|
+
FROM oven/bun:latest AS runner
|
|
27
|
+
WORKDIR /app
|
|
28
|
+
|
|
29
|
+
ENV NODE_ENV=production
|
|
30
|
+
ENV HOST=0.0.0.0
|
|
31
|
+
ENV PORT=3000
|
|
32
|
+
|
|
33
|
+
COPY --from=builder /app/.output ./
|
|
34
|
+
|
|
35
|
+
EXPOSE 3000
|
|
36
|
+
|
|
37
|
+
CMD ["bun", "run", "server/index.mjs"]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 3. Install Thunder
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun add @thunder-so/thunder --development
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 4. Create Stack File
|
|
47
|
+
|
|
48
|
+
Create `stack/prod.ts`:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Cdk, Fargate, type FargateProps } from '@thunder-so/thunder';
|
|
52
|
+
|
|
53
|
+
const config: FargateProps = {
|
|
54
|
+
env: {
|
|
55
|
+
account: '123456789012',
|
|
56
|
+
region: 'us-east-1',
|
|
57
|
+
},
|
|
58
|
+
application: 'myapp',
|
|
59
|
+
service: 'web',
|
|
60
|
+
environment: 'prod',
|
|
61
|
+
rootDir: '.',
|
|
62
|
+
|
|
63
|
+
serviceProps: {
|
|
64
|
+
dockerFile: 'Dockerfile',
|
|
65
|
+
architecture: Cdk.aws_ecs.CpuArchitecture.ARM64,
|
|
66
|
+
cpu: 512,
|
|
67
|
+
memorySize: 1024,
|
|
68
|
+
port: 3000,
|
|
69
|
+
desiredCount: 1,
|
|
70
|
+
healthCheckPath: '/',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
new Fargate(
|
|
75
|
+
new Cdk.App(),
|
|
76
|
+
`${config.application}-${config.service}-${config.environment}-stack`,
|
|
77
|
+
config
|
|
78
|
+
);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 5. Deploy
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx cdk deploy --app "npx tsx stack/prod.ts" --profile default
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Custom Domain with HTTPS
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const config: FargateProps = {
|
|
91
|
+
// ...
|
|
92
|
+
domain: 'app.example.com',
|
|
93
|
+
regionalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123',
|
|
94
|
+
hostedZoneId: 'Z1234567890ABC',
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Environment Variables
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
serviceProps: {
|
|
102
|
+
// ...
|
|
103
|
+
variables: [
|
|
104
|
+
{ NODE_ENV: 'production' },
|
|
105
|
+
],
|
|
106
|
+
secrets: [
|
|
107
|
+
{ key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:/myapp/db-abc123' },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Related
|
|
113
|
+
|
|
114
|
+
- [fargate-basic.md](../fargate-basic.md) - Fargate construct reference
|
|
115
|
+
- [nuxt-serverless.md](./nuxt-serverless.md) - Nuxt on Lambda
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# Deploy Nuxt to AWS Lambda + S3 + CloudFront
|
|
2
|
+
|
|
3
|
+
Deploy your Nuxt app with server-side rendering to AWS using Thunder's `Nuxt` construct. This creates a hybrid architecture: [Lambda](https://aws.amazon.com/lambda/) handles SSR and API routes, [S3](https://aws.amazon.com/s3/) hosts static assets, and [CloudFront](https://aws.amazon.com/cloudfront/) unifies both.
|
|
4
|
+
|
|
5
|
+
## 1. Create a New Nuxt Project
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx nuxi@latest init my-nuxt-app
|
|
9
|
+
cd my-nuxt-app
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Reference: [Nuxt Installation Docs](https://nuxt.com/docs/getting-started/installation)
|
|
13
|
+
|
|
14
|
+
## 2. Configure Nitro for AWS Lambda
|
|
15
|
+
|
|
16
|
+
Nuxt uses [Nitro](https://nitro.unjs.io/) for server-side rendering. Set the `aws-lambda` preset via environment variable:
|
|
17
|
+
|
|
18
|
+
Create `.env`:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
NITRO_PRESET=aws-lambda
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or set it in `nuxt.config.ts`:
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
export default defineNuxtConfig({
|
|
28
|
+
nitro: {
|
|
29
|
+
preset: 'aws-lambda',
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Reference: [Nitro AWS Lambda Preset](https://nitro.build/deploy/providers/aws)
|
|
35
|
+
|
|
36
|
+
## 3. Build Your App
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bun run build
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
This generates:
|
|
43
|
+
- `.output/server/` - Lambda handler
|
|
44
|
+
- `.output/public/` - Static assets for S3
|
|
45
|
+
|
|
46
|
+
## 4. Install Thunder
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bun add @thunder-so/thunder --development
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 5. Create Stack File
|
|
53
|
+
|
|
54
|
+
Create `stack/prod.ts`:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { Cdk, Nuxt, type NuxtProps } from '@thunder-so/thunder';
|
|
58
|
+
|
|
59
|
+
const config: NuxtProps = {
|
|
60
|
+
env: {
|
|
61
|
+
account: '123456789012',
|
|
62
|
+
region: 'us-east-1',
|
|
63
|
+
},
|
|
64
|
+
application: 'myapp',
|
|
65
|
+
service: 'web',
|
|
66
|
+
environment: 'prod',
|
|
67
|
+
rootDir: '.',
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
new Nuxt(
|
|
71
|
+
new Cdk.App(),
|
|
72
|
+
`${config.application}-${config.service}-${config.environment}-stack`,
|
|
73
|
+
config
|
|
74
|
+
);
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## 6. Deploy
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx cdk deploy --app "npx tsx stack/prod.ts" --profile default
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Custom Domain
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
const config: NuxtProps = {
|
|
87
|
+
// ...
|
|
88
|
+
domain: 'app.example.com',
|
|
89
|
+
hostedZoneId: 'Z1234567890ABC',
|
|
90
|
+
globalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123',
|
|
91
|
+
regionalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/def-456',
|
|
92
|
+
};
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Environment Variables
|
|
96
|
+
|
|
97
|
+
```typescript
|
|
98
|
+
serverProps: {
|
|
99
|
+
variables: [
|
|
100
|
+
{ NODE_ENV: 'production' },
|
|
101
|
+
],
|
|
102
|
+
secrets: [
|
|
103
|
+
{ key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:/myapp/db-abc123' },
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Performance Tuning
|
|
109
|
+
|
|
110
|
+
```typescript
|
|
111
|
+
serverProps: {
|
|
112
|
+
memorySize: 1792,
|
|
113
|
+
timeout: 10,
|
|
114
|
+
keepWarm: true,
|
|
115
|
+
tracing: true,
|
|
116
|
+
},
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Related
|
|
120
|
+
|
|
121
|
+
- [serverless.md](../serverless.md) - Serverless construct overview
|
|
122
|
+
- [lambda-basic.md](../lambda-basic.md) - Lambda construct reference
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# Deploy Solid Start to AWS Fargate
|
|
2
|
+
|
|
3
|
+
Run your Solid Start app with full SSR support on [AWS ECS Fargate](https://aws.amazon.com/fargate/) using Thunder's `Fargate` construct.
|
|
4
|
+
|
|
5
|
+
## 1. Create a New Solid Start Project
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx create-solid@latest my-solid-app
|
|
9
|
+
cd my-solid-app
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Reference: [Solid Start Getting Started](https://docs.solidjs.com/solid-start/getting-started)
|
|
13
|
+
|
|
14
|
+
## 2. Create Dockerfile
|
|
15
|
+
|
|
16
|
+
```dockerfile
|
|
17
|
+
FROM oven/bun:latest AS builder
|
|
18
|
+
WORKDIR /app
|
|
19
|
+
|
|
20
|
+
COPY package.json bun.lockb ./
|
|
21
|
+
RUN bun install --frozen-lockfile
|
|
22
|
+
|
|
23
|
+
COPY . .
|
|
24
|
+
RUN bun run build
|
|
25
|
+
|
|
26
|
+
FROM oven/bun:latest AS runner
|
|
27
|
+
WORKDIR /app
|
|
28
|
+
|
|
29
|
+
ENV NODE_ENV=production
|
|
30
|
+
ENV HOST=0.0.0.0
|
|
31
|
+
ENV PORT=3000
|
|
32
|
+
|
|
33
|
+
COPY --from=builder /app/.output ./
|
|
34
|
+
|
|
35
|
+
EXPOSE 3000
|
|
36
|
+
|
|
37
|
+
CMD ["bun", "run", "server/index.mjs"]
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 3. Install Thunder
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun add @thunder-so/thunder --development
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 4. Create Stack File
|
|
47
|
+
|
|
48
|
+
Create `stack/prod.ts`:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Cdk, Fargate, type FargateProps } from '@thunder-so/thunder';
|
|
52
|
+
|
|
53
|
+
const config: FargateProps = {
|
|
54
|
+
env: {
|
|
55
|
+
account: '123456789012',
|
|
56
|
+
region: 'us-east-1',
|
|
57
|
+
},
|
|
58
|
+
application: 'myapp',
|
|
59
|
+
service: 'web',
|
|
60
|
+
environment: 'prod',
|
|
61
|
+
rootDir: '.',
|
|
62
|
+
|
|
63
|
+
serviceProps: {
|
|
64
|
+
dockerFile: 'Dockerfile',
|
|
65
|
+
architecture: Cdk.aws_ecs.CpuArchitecture.ARM64,
|
|
66
|
+
cpu: 512,
|
|
67
|
+
memorySize: 1024,
|
|
68
|
+
port: 3000,
|
|
69
|
+
desiredCount: 1,
|
|
70
|
+
healthCheckPath: '/',
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
new Fargate(
|
|
75
|
+
new Cdk.App(),
|
|
76
|
+
`${config.application}-${config.service}-${config.environment}-stack`,
|
|
77
|
+
config
|
|
78
|
+
);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 5. Deploy
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
npx cdk deploy --app "npx tsx stack/prod.ts" --profile default
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Custom Domain with HTTPS
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const config: FargateProps = {
|
|
91
|
+
// ...
|
|
92
|
+
domain: 'app.example.com',
|
|
93
|
+
regionalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123',
|
|
94
|
+
hostedZoneId: 'Z1234567890ABC',
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Environment Variables
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
serviceProps: {
|
|
102
|
+
// ...
|
|
103
|
+
variables: [
|
|
104
|
+
{ NODE_ENV: 'production' },
|
|
105
|
+
],
|
|
106
|
+
secrets: [
|
|
107
|
+
{ key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:/myapp/db-abc123' },
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Related
|
|
113
|
+
|
|
114
|
+
- [fargate-basic.md](../fargate-basic.md) - Fargate construct reference
|
|
115
|
+
- [solidstart-serverless.md](./solidstart-serverless.md) - Solid Start on Lambda
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Deploy Solid Start to AWS Lambda + S3 + CloudFront
|
|
2
|
+
|
|
3
|
+
Deploy your Solid Start app with server-side rendering to AWS using Thunder's `SolidStart` construct. This creates a hybrid architecture: [Lambda](https://aws.amazon.com/lambda/) handles SSR and API routes, [S3](https://aws.amazon.com/s3/) hosts static assets, and [CloudFront](https://aws.amazon.com/cloudfront/) unifies both.
|
|
4
|
+
|
|
5
|
+
## 1. Create a New Solid Start Project
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
bunx create-solid@latest my-solid-app
|
|
9
|
+
cd my-solid-app
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Reference: [Solid Start Getting Started](https://docs.solidjs.com/solid-start/getting-started)
|
|
13
|
+
|
|
14
|
+
## 2. Configure Nitro for AWS Lambda
|
|
15
|
+
|
|
16
|
+
Solid Start uses [Nitro](https://nitro.unjs.io/) for server-side rendering. Set the `aws-lambda` preset in `app.config.ts`:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { defineConfig } from '@solidjs/start/config';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
server: {
|
|
23
|
+
preset: 'aws-lambda',
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Reference: [Nitro AWS Lambda Preset](https://nitro.build/deploy/providers/aws)
|
|
29
|
+
|
|
30
|
+
## 3. Build Your App
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
bun run build
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
This generates:
|
|
37
|
+
- `.output/server/` - Lambda handler
|
|
38
|
+
- `.output/public/` - Static assets for S3
|
|
39
|
+
|
|
40
|
+
## 4. Install Thunder
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
bun add @thunder-so/thunder --development
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 5. Create Stack File
|
|
47
|
+
|
|
48
|
+
Create `stack/prod.ts`:
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
import { Cdk, SolidStart, type SolidStartProps } from '@thunder-so/thunder';
|
|
52
|
+
|
|
53
|
+
const config: SolidStartProps = {
|
|
54
|
+
env: {
|
|
55
|
+
account: '123456789012',
|
|
56
|
+
region: 'us-east-1',
|
|
57
|
+
},
|
|
58
|
+
application: 'myapp',
|
|
59
|
+
service: 'web',
|
|
60
|
+
environment: 'prod',
|
|
61
|
+
rootDir: '.',
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
new SolidStart(
|
|
65
|
+
new Cdk.App(),
|
|
66
|
+
`${config.application}-${config.service}-${config.environment}-stack`,
|
|
67
|
+
config
|
|
68
|
+
);
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 6. Deploy
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npx cdk deploy --app "npx tsx stack/prod.ts" --profile default
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Custom Domain
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const config: SolidStartProps = {
|
|
81
|
+
// ...
|
|
82
|
+
domain: 'app.example.com',
|
|
83
|
+
hostedZoneId: 'Z1234567890ABC',
|
|
84
|
+
globalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/abc-123',
|
|
85
|
+
regionalCertificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/def-456',
|
|
86
|
+
};
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Environment Variables
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
serverProps: {
|
|
93
|
+
variables: [
|
|
94
|
+
{ NODE_ENV: 'production' },
|
|
95
|
+
],
|
|
96
|
+
secrets: [
|
|
97
|
+
{ key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:/myapp/db-abc123' },
|
|
98
|
+
],
|
|
99
|
+
},
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Performance Tuning
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
serverProps: {
|
|
106
|
+
memorySize: 1792,
|
|
107
|
+
timeout: 10,
|
|
108
|
+
keepWarm: true,
|
|
109
|
+
tracing: true,
|
|
110
|
+
},
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Related
|
|
114
|
+
|
|
115
|
+
- [serverless.md](../serverless.md) - Serverless construct overview
|
|
116
|
+
- [lambda-basic.md](../lambda-basic.md) - Lambda construct reference
|