-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsst.config.ts
More file actions
70 lines (63 loc) · 1.95 KB
/
sst.config.ts
File metadata and controls
70 lines (63 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* eslint-disable @typescript-eslint/triple-slash-reference */
/// <reference path="./.sst/platform/config.d.ts" />
const name = "sstart";
export default $config({
app(input) {
return {
name: name,
removal: input?.stage === "production" ? "retain" : "remove",
home: "aws",
providers: {
aws: {
region: "us-east-1",
profile: process.env.GITHUB_ACTIONS
? undefined
: input?.stage === "production"
? "mesa-production"
: "mesa-development",
},
},
};
},
async run() {
const isPermanentStage = $app.stage === "production" || $app.stage === "dev";
// const betterAuthSecret = new sst.Secret("BetterAuthSecret");
const vpc = isPermanentStage
? new sst.aws.Vpc(`${name}-vpc`, { bastion: true, nat: "ec2" })
: sst.aws.Vpc.get(`${name}-vpc`, "vpc-057d1174bade06382");
const database = isPermanentStage
? new sst.aws.Postgres(`${name}-database`, { vpc: vpc as sst.aws.Vpc, proxy: true })
: sst.aws.Postgres.get(`${name}-database`, {
id: `${name}-dev-databaseinstance`,
proxyId: `${name}-dev-databaseproxy`,
});
const webApp = new sst.aws.TanstackStart(`${name}-app`, {
link: [database],
vpc,
dev: { command: "pnpm run dev:app" },
});
if ($app.stage === "production") {
const databasePush = new sst.aws.Function(`${name}-database-push`, {
handler: "app/database/database-push.databasePush",
link: [database],
vpc,
});
new aws.lambda.Invocation(`${name}-database-push-invocation`, {
functionName: databasePush.name,
input: JSON.stringify({
now: new Date().toISOString(),
}),
});
}
new sst.x.DevCommand("Studio", {
link: [database],
dev: {
command: "pnpm db:studio",
autostart: true,
},
});
return {
webApp: webApp.url,
};
},
});