Back to list
chandima

sst

by chandima

0🍴 0📅 Jan 21, 2026

SKILL.md


name: sst description: SST infrastructure patterns for AWS deployments including Functions, Buckets, Databases, Queues, and Pulumi integration. Use when building serverless infrastructure with SST.

SST Infrastructure

SST (Serverless Stack) patterns for AWS infrastructure as code with type-safe resource linking.

Core Philosophy

  • All infrastructure lives in sst.config.ts
  • Never configure AWS manually
  • Use SST components, fall back to Pulumi AWS when needed
  • Type-safe resource access via Resource import

Project Structure

Drop-in Mode (Single Config)

// sst.config.ts
export default $config({
  app(input) {
    return {
      name: "my-app",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "aws",
    };
  },
  async run() {
    const bucket = new sst.aws.Bucket("Uploads");
    new sst.aws.Astro("Web", {
      link: [bucket],
    });
  },
});

Monorepo (Split Config)

// sst.config.ts
export default $config({
  app(input) { /* ... */ },
  async run() {
    await import("./infra/storage");
    await import("./infra/database");
    await import("./infra/web");
  },
});

// infra/storage.ts
export const bucket = new sst.aws.Bucket("Uploads");

// infra/web.ts
import { bucket } from "./storage";
new sst.aws.Astro("Web", {
  link: [bucket],
});

Local Development

Use concurrently to run SST and Astro dev in parallel:

{
  "scripts": {
    "dev": "concurrently \"sst dev\" \"&& npm run dev\"",
    "remove": "sst remove --stage dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro",
    "sst": "sst"
  },
  "devDependencies": {
    "concurrently": "^9.2.1"
  }
}

Component Selection

NeedComponentWhen
Web appsst.aws.AstroDefault for Astro sites
API routessst.aws.FunctionShort tasks (<15s)
File storagesst.aws.BucketUploads, assets
Relational datasst.aws.PostgresDefault database
Key-valuesst.aws.DynamoHigh-scale, simple queries
Background jobssst.aws.QueueAsync processing
Event fan-outsst.aws.BusMultiple subscribers
Scheduled taskssst.aws.CronPeriodic jobs
Live updatessst.aws.RealtimeWebSockets

Resource Linking

// Define resources
const bucket = new sst.aws.Bucket("Uploads");
const database = new sst.aws.Postgres("Database", { vpc });

// Link to Astro
new sst.aws.Astro("Web", {
  link: [bucket, database],
});
// Access in code
import { Resource } from "sst";

// Type-safe access
const bucketName = Resource.Uploads.name;
const dbHost = Resource.Database.host;

Secrets Management

# Set secret per stage
sst secret set StripeKey sk_live_xxx --stage production
sst secret set StripeKey sk_test_xxx --stage dev
// Reference in config
const stripe = new sst.Secret("StripeKey");

new sst.aws.Function("Webhook", {
  handler: "src/webhook.handler",
  link: [stripe],
});

// Access in code
import { Resource } from "sst";
const client = new Stripe(Resource.StripeKey.value);

Stage-Aware Configuration

export default $config({
  app(input) {
    return {
      name: "my-app",
      removal: input?.stage === "production" ? "retain" : "remove",
      home: "aws",
    };
  },
  async run() {
    const isProd = $app.stage === "production";
    
    const database = new sst.aws.Postgres("Database", {
      vpc,
      scaling: {
        min: isProd ? "2 ACU" : "0.5 ACU",
        max: isProd ? "16 ACU" : "2 ACU",
      },
    });
  },
});

Pulumi Integration

Use transform to customize underlying resources:

const bucket = new sst.aws.Bucket("Uploads", {
  transform: {
    bucket: (args) => {
      args.forceDestroy = $app.stage !== "production";
      args.tags = { CostCenter: "engineering" };
    },
  },
});

Use raw Pulumi when SST lacks a component:

import * as aws from "@pulumi/aws";

const logGroup = new aws.cloudwatch.LogGroup("AppLogs", {
  retentionInDays: 30,
});

Anti-Patterns

// Bad: Hardcoded credentials
new S3Client({ credentials: { ... } });

// Good: SST handles credentials
const client = new S3Client({});

// Bad: Hardcoded resource names
const bucketName = "my-app-uploads-bucket";

// Good: Use Resource
import { Resource } from "sst";
const bucketName = Resource.Uploads.name;

// Bad: Environment variables for resources
environment: { BUCKET_NAME: bucket.name }

// Good: Linking
link: [bucket]

Deployment

sst dev                      # Local development
sst deploy --stage dev       # Deploy to stage
sst deploy --stage production
sst remove --stage pr-123    # Cleanup PR environment

References

See .apm/instructions/sst.instructions.md for complete patterns including:

  • Async processing (Queues, Event Bus)
  • Realtime/WebSocket setup
  • Database configuration
  • Cron job patterns

Score

Total Score

45/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

0/5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon