-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsst.config.ts
59 lines (55 loc) · 1.63 KB
/
sst.config.ts
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
import type { SSTConfig } from 'sst';
import { Bucket, Config, NextjsSite } from 'sst/constructs';
import * as s3 from 'aws-cdk-lib/aws-s3';
import { env } from '~/env.mjs';
export default {
config(_input) {
return {
name: 'newsite',
region: 'us-east-1',
};
},
stacks(app) {
app.stack(function Site({ stack }) {
const bucket = new Bucket(stack, 'bucketid', {
cdk: {
bucket: s3.Bucket.fromBucketArn(
stack,
env.S3_BUCKET_NAME,
env.S3_BUCKET_ARN
),
},
});
const site = new NextjsSite(stack, 'site', {
customDomain: {
domainName:
stack.stage === 'prod'
? 'migotos.com'
: `${stack.stage}.migotos.com`,
domainAlias: stack.stage === 'prod' ? 'www.migotos.com' : undefined,
hostedZone: 'migotos.com',
},
runtime: 'nodejs20.x',
environment: {
NEXTAUTH_URL:
app.mode === 'dev'
? 'http://localhost:3000'
: app.stage === 'prod'
? env.NEXTAUTH_URL
: env.NEXTAUTH_URL_STAGING,
DATABASE_URL:
app.stage === 'prod' ? env.DATABASE_URL : env.DATABASE_URL_DEV,
},
bind: [bucket],
buildCommand: 'npx @opennextjs/[email protected] build',
permissions: ['ssm'],
});
new Config.Parameter(stack, 'FRONTEND_DISTRIBUTION_ID', {
value: site.cdk?.distribution?.distributionId ?? 'localhost',
});
stack.addOutputs({
SiteUrl: site.customDomainUrl ?? site.url,
});
});
},
} satisfies SSTConfig;