Examples

Basic Deployment

typescript
import { defineConfig } from 'scf-deploy';

export default defineConfig({
  app: 'my-site',
  region: 'ap-northeast-2',
  s3: {
    bucketName: 'my-site-bucket-abc123',
  },
  cloudfront: {
    enabled: true,
  },
});
bash
npx scf-deploy deploy

SPA (Single Page Application)

For React, Vue, or other SPAs, configure 404 redirect to index.html:

typescript
import { defineConfig } from 'scf-deploy';

export default defineConfig({
  app: 'my-spa',
  region: 'ap-northeast-2',
  s3: {
    bucketName: 'my-spa-bucket-abc123',
  },
  cloudfront: {
    enabled: true,
    errorPages: [
      {
        errorCode: 404,
        responseCode: 200,
        responsePath: '/index.html',
      },
    ],
  },
});

Multi-Environment

Use environments for dev/prod configuration:

typescript
import { defineConfig } from 'scf-deploy';

export default defineConfig({
  app: 'my-site',
  region: 'ap-northeast-2',
  s3: {
    bucketName: 'my-site-dev',
  },
  cloudfront: {
    enabled: false,
  },
  environments: {
    prod: {
      s3: {
        bucketName: 'my-site-prod',
      },
      cloudfront: {
        enabled: true,
        priceClass: 'PriceClass_All',
      },
    },
  },
});
bash
# Deploy to dev (default)
npx scf-deploy deploy

# Deploy to prod
npx scf-deploy deploy --env prod

Custom Domain

typescript
import { defineConfig } from 'scf-deploy';

export default defineConfig({
  app: 'my-site',
  region: 'ap-northeast-2',
  s3: {
    bucketName: 'my-site-bucket-abc123',
  },
  cloudfront: {
    enabled: true,
    customDomain: {
      domainName: 'www.example.com',
      // Optional: provide certificate ARN
      // If omitted, auto-created with Route53
      certificateArn: 'arn:aws:acm:us-east-1:123456789012:certificate/xxxxx',
    },
  },
});

GitHub Actions

yaml
# .github/workflows/deploy.yml
name: Deploy

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: '18'
      - run: npm ci
      - run: npm run build
      - run: npx scf-deploy deploy --env prod
        env:
          AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
          AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

Add secrets in GitHub repository settings:

  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

Next Steps

2 min readLast updated: 2025-11-25