SvelteKit adapter for deploying and managing AWS ECS Fargate infrastructure (Day 1 & Day 2 operations).
This adapter wraps @sveltejs/adapter-node to compile your SvelteKit application and automate the provisioning, deployment, and ongoing management of a highly available AWS Fargate architecture.
Building the app is only half the battle. This adapter hooks directly into your SvelteKit build process to solve both Day 1 and Day 2 platform engineering challenges natively:
- Day 1 (Deployment): Automatically generates optimized Dockerfiles, Fargate Terraform modules, and GitHub Actions CI/CD pipelines natively tailored to your SvelteKit SSR app.
- Day 2 (Management): Zero-secret OIDC deployments, ALB health checks, and seamless teardown capabilities.
- DevSecOps Built-In: Generates a Multi-Stage Dockerfile that natively bypasses CI/CD loops, strips global NPM binaries in production for zero-CVE Trivy scans, and ensures least-privilege container execution.
First, remove the default SvelteKit auto-adapter to prevent conflicts, then install our AWS Fargate adapter as a development dependency:
npm uninstall @sveltejs/adapter-auto
npm install -D svelte-adapter-deploy-stackSvelteKit recently updated how adapters are configured. Follow the steps for your specific version.
Update your vite.config.ts to swap out the default adapter. Ensure you completely remove the old @sveltejs/adapter-auto import!
import adapter from 'svelte-adapter-deploy-stack'; // <-- 1. Swap the import
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
sveltekit({
// 2. Configure our adapter for Day 1 and Day 2 management
adapter: adapter({
// Optional: Pass flags to customize your Fargate infrastructure.
// See full options: [https://github.com/anton-codes-iac/deploy-stack/blob/main/docs/guides/headless.md](https://github.com/anton-codes-iac/deploy-stack/blob/main/docs/guides/headless.md)
region: 'us-east-2',
size: 'micro'
})
})
]
});If your project uses a svelte.config.js file at the root, update it to use the adapter instead:
import adapter from 'svelte-adapter-deploy-stack';
import { vitePreprocess } from '@sveltejs/vite-plugin-svelte';
/** @type {import('@sveltejs/kit').Config} */
const config = {
preprocess: vitePreprocess(),
kit: {
adapter: adapter({
region: 'us-east-2',
size: 'micro'
})
}
};
export default config;- Build: Run
npm run build. SvelteKit compiles your SSR frontend. - Generate: The adapter intercepts the end of the build to safely generate the
terraform/,.github/, andDockerfileinside your project root. - Deploy (Day 1): Run
npx --yes deploy-stack applyin your terminal to provision the AWS infrastructure. - Manage (Day 2): Push to GitHub. The generated CI/CD pipeline will automatically deploy all future changes securely using IAM OIDC (no long-lived AWS keys).
- Teardown: Run
npx --yes deploy-stack destroyto completely remove all resources and stop AWS billing.
This tool provisions real AWS resources which will incur charges on your AWS bill. An ECS Fargate cluster with an Application Load Balancer running 24/7 typically costs around ~$15 - $20/month minimum, depending on your region and configuration.
Disclaimer: The maintainers are not responsible for any unexpected AWS charges, security breaches, or data loss. Please monitor your AWS Billing Dashboard.
MIT