Skip to content

Latest commit

 

History

History
119 lines (89 loc) · 2.53 KB

File metadata and controls

119 lines (89 loc) · 2.53 KB

Deploy Solid Start to AWS Lambda + S3 + CloudFront

Deploy your Solid Start app with server-side rendering to AWS using Thunder's SolidStart construct. This creates a hybrid architecture: Lambda handles SSR and API routes, S3 hosts static assets, and CloudFront unifies both.

1. Create a New Solid Start Project

bunx create-solid@latest my-solid-app
cd my-solid-app

Reference: Solid Start Getting Started

2. Configure Nitro for AWS Lambda

Solid Start uses Nitro for server-side rendering. Set the aws-lambda preset in app.config.ts:

import { defineConfig } from "@solidjs/start/config";

export default defineConfig({
  server: {
    preset: "aws-lambda",
  },
});

Reference: Nitro AWS Lambda Preset

3. Build Your App

bun run build

This generates:

  • .output/server/ - Lambda handler
  • .output/public/ - Static assets for S3

4. Install Thunder

bun add @thunder-so/thunder --development

5. Create Stack File

Create stack/prod.ts:

import { Cdk, SolidStart, type SolidStartProps } from "@thunder-so/thunder";

const config: SolidStartProps = {
  env: {
    account: "123456789012",
    region: "us-east-1",
  },
  application: "myapp",
  service: "web",
  environment: "prod",
  rootDir: ".",
};

new SolidStart(
  new Cdk.App(),
  `${config.application}-${config.service}-${config.environment}-stack`,
  config,
);

6. Deploy

npx cdk deploy --app "npx tsx stack/prod.ts" --profile default

Custom Domain

const config: SolidStartProps = {
  // ...
  domain: "app.example.com",
  hostedZoneId: "Z1234567890ABC",
  globalCertificateArn:
    "arn:aws:acm:us-east-1:123456789012:certificate/abc-123",
  regionalCertificateArn:
    "arn:aws:acm:us-east-1:123456789012:certificate/def-456",
};

Environment Variables

serverProps: {
  variables: [
    { NODE_ENV: 'production' },
  ],
  secrets: [
    { key: 'DATABASE_URL', resource: 'arn:aws:secretsmanager:us-east-1:123456789012:secret:/myapp/db-abc123' },
  ],
},

Performance Tuning

serverProps: {
  memorySize: 1792,
  timeout: 10,
  keepWarm: true,
  tracing: true,
},

Related