-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinfrastructure.ts
74 lines (63 loc) · 2.11 KB
/
infrastructure.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env node
import 'source-map-support/register'
import * as cdk from 'aws-cdk-lib'
import * as consts from '../consts'
import { Tags } from 'aws-cdk-lib'
import { VueSiteStackProps } from '../lib/vue-site-stack'
import { getConfig } from '../config'
import { ApiBaseStack } from '../lib/api-base-stack'
import { STACK_NAME } from '../consts'
import { EcsStack } from '../lib/ecs-stack'
import { NetworkingStack } from '../lib/networking-stack'
import { ApiStack } from '../lib/api-stack'
const config = getConfig()
const env = process.env.ENV
if (!env) {
console.error('No ENV env var defined')
process.exit(1)
}
const isProd = env === 'prod'
const isDev = env === 'dev'
const isDevEnv = !['prod', 'staging'].includes(env)
const region = config.REGION
// TODO: planning to use 1 for both envs
// let currentEnvironmentAccount = consts.ACCOUNT.PROD;
let currentEnvironmentAccount = consts.ACCOUNT.DEV
if (isDevEnv) {
currentEnvironmentAccount = consts.ACCOUNT.DEV
}
const app = new cdk.App()
Tags.of(app).add('Env', env)
const networkingEnv = isDevEnv ? 'dev' : env
const networkingStack = new NetworkingStack(
app,
STACK_NAME.networkingAndEcsStackName(networkingEnv),
{
env: { account: currentEnvironmentAccount, region },
envName: networkingEnv,
}
)
Tags.of(networkingStack).add('Env', networkingEnv)
const ecsStack = new EcsStack(app, STACK_NAME.ecsStackName(env), {
env: { account: currentEnvironmentAccount, region },
envName: env,
vpc: networkingStack.mainVpc,
})
const apiBaseStack = new ApiBaseStack(app, STACK_NAME.apiBaseStackName(env), {
env: { account: currentEnvironmentAccount, region },
envName: env,
ecsVpc: networkingStack.mainVpc,
ecsCluster: ecsStack.ecsCluster,
})
const apiStack = new ApiStack(app, STACK_NAME.apiStackName(env), {
env: { account: currentEnvironmentAccount, region },
envName: env,
ecsVpc: networkingStack.mainVpc,
ecsCluster: ecsStack.ecsCluster,
db: apiBaseStack.database,
// apiJwtSecret: apiStack.apiJwtSecret,
})
new VueSiteStackProps(app, STACK_NAME.vueSiteStackName(env), {
env: { account: currentEnvironmentAccount, region },
envName: env,
})