-
Notifications
You must be signed in to change notification settings - Fork 0
/
bin.ts
48 lines (40 loc) · 1.35 KB
/
bin.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
import { App } from 'aws-cdk-lib';
import { Builder } from '@sls-next/lambda-at-edge';
import { writeJSON } from '@bevry/jsonfile';
import { getConfig, STAGE } from './config';
import { Next } from './stacks/next';
import { DNS } from './stacks/dns';
const builder = new Builder('.', './build', { args: ['build'] });
const config = getConfig();
const main = async () => {
const app = new App();
if (config.stage !== STAGE.DEV) {
// This is a hacky way of distributing secrets/config to a Lambda@Edge Function as they cannot use environment variables
writeJSON('config.json', config);
}
// Build the NextJS app
await builder.build();
const dNSStack = new DNS(app, `Shared${config.codenameCapitalized}DNS`, {
terminationProtection: config.isProd,
env: {
account: process.env.AWS_DEFAULT_ACCOUNT_ID,
region: process.env.AWS_DEFAULT_REGION || 'us-east-1',
},
analyticsReporting: true,
description: 'The DNS stack',
config,
});
// Deploy the NextJS app
new Next(app, `${config.prefixCamelCase}Next`, {
terminationProtection: config.isProd,
env: {
account: process.env.AWS_DEFAULT_ACCOUNT_ID,
region: process.env.AWS_DEFAULT_REGION || 'us-east-1',
},
analyticsReporting: true,
description: 'The Next stack',
config,
zoneId: dNSStack.zoneId,
}).addDependency(dNSStack);
};
main();