Last active
May 11, 2025 15:15
-
-
Save danieldunderfelt/016c2171f6b4f33445037a90af8b9659 to your computer and use it in GitHub Desktop.
SST config with circular dependencies
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async run() { | |
const vpc = new sst.aws.Vpc('AppVPC') | |
const database = new sst.aws.Aurora('AppDB', { | |
engine: 'postgres', | |
scaling: { | |
min: '1 ACU', | |
max: '10 ACU', | |
}, | |
dataApi: true, | |
vpc, | |
dev: { | |
username: 'postgres', | |
password: 'password', | |
database: 'local', | |
port: 5432, | |
}, | |
}) | |
const siteInfo = new sst.Linkable<{ url: string }>('SiteInfo', { | |
properties: { | |
url: 'placeholder string', | |
}, | |
}) | |
const cluster = new sst.aws.Cluster('AppCluster', { vpc }) | |
const server = new sst.aws.Service('AppService', { | |
cluster, | |
loadBalancer: { | |
ports: [{ listen: '80/http', forward: '3000/http' }], | |
}, | |
dev: { | |
command: 'bun dev:server', | |
}, | |
link: [database, siteInfo], | |
}) | |
const web = new sst.aws.StaticSite('AppWeb', { | |
build: { | |
command: 'bun run build', | |
output: 'dist', | |
}, | |
environment: { | |
VITE_APP_URL: $dev ? 'http://localhost:3000' : server.url, | |
}, | |
dev: { | |
command: 'bun dev:client', | |
}, | |
}) | |
web.getSSTLink().properties.url.apply((val) => { | |
siteInfo.properties.url = $dev ? 'http://localhost:5173' : val | |
}) | |
return { | |
api: server.url, | |
web: web.url, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment