-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
129 lines (115 loc) · 3.79 KB
/
app.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
import * as cdk from "aws-cdk-lib";
import {
StageConfig,
BetaStageConfig,
ProdStageConfig,
} from "./lib/constants/stage-config";
import { PsIngestionTeamsTable } from "./lib/infrastructure/dynamodb/ps-ingestion-teams-table";
import {
PsIngestionStack,
PsIngestionStackProps,
} from "./lib/stacks/ps-ingestion-stack";
import {
PsTeamsServiceStack,
PsTeamsServiceStackProps,
} from "./lib/stacks/ps-teams-service-stack";
import { LambdaRestApi } from "aws-cdk-lib/aws-apigateway";
import {
StatsugiriApiGatewayStack,
StatsugiriApiGatewayStackProps,
} from "./lib/stacks/statsugiri-api-gateway-stack";
import { STATSUGIRI_GG_DOMAIN } from "./lib/constants/statsugiri-constants";
export class StatsugiriInfrastructureApp extends cdk.App {
public setupBeta() {
const stage = this.createBetaStage();
return this;
}
public setupProd() {
const stage = this.createProdStage();
return this;
}
/**
* Creates a beta stage
* @returns the created stage
*/
private createBetaStage() {
let betaStacks = new Array<cdk.Stack>();
const psIngestionStack = this.setupPsIngestionStack(BetaStageConfig);
const psTeamsServiceStack = this.setupPsTeamsServiceStack(
BetaStageConfig,
psIngestionStack.teamsTable
);
betaStacks.push(psIngestionStack);
betaStacks.push(psTeamsServiceStack);
console.log(psTeamsServiceStack.psTeamsServiceApi);
betaStacks.push(
this.setupStatsugiriApiGatewayStack(
BetaStageConfig,
STATSUGIRI_GG_DOMAIN,
psTeamsServiceStack.psTeamsServiceApi.lambdaApi
)
);
}
/**
* Creates a beta stage
* @returns the created stage
*/
private createProdStage() {
let prodStacks = new Array<cdk.Stack>();
const psIngestionStack = this.setupPsIngestionStack(ProdStageConfig);
const psTeamsServiceStack = this.setupPsTeamsServiceStack(
ProdStageConfig,
psIngestionStack.teamsTable
);
prodStacks.push(psIngestionStack);
prodStacks.push(psTeamsServiceStack);
prodStacks.push(
this.setupStatsugiriApiGatewayStack(
ProdStageConfig,
STATSUGIRI_GG_DOMAIN,
psTeamsServiceStack.psTeamsServiceApi.lambdaApi
)
);
}
private setupPsIngestionStack(stageConfig: StageConfig) {
const psIngestionStackProps: PsIngestionStackProps = {
stageConfig: stageConfig,
};
return new PsIngestionStack(
this,
`PsIngestionStack-${stageConfig.stageName}`,
psIngestionStackProps
);
}
private setupPsTeamsServiceStack(
stageConfig: StageConfig,
teamsTable: PsIngestionTeamsTable
) {
const psTeamsServiceStackProps: PsTeamsServiceStackProps = {
stageConfig: stageConfig,
teamsTable: teamsTable,
};
return new PsTeamsServiceStack(
this,
`PsTeamsServiceStack-${stageConfig.stageName}`,
psTeamsServiceStackProps
);
}
private setupStatsugiriApiGatewayStack(
stageConfig: StageConfig,
domainName: string,
psTeamsServiceApi: LambdaRestApi
) {
const statsugiriApiGatewayStackProps: StatsugiriApiGatewayStackProps = {
stageConfig: stageConfig,
domainName: domainName,
psTeamsServiceApi: psTeamsServiceApi,
};
return new StatsugiriApiGatewayStack(
this,
`StatsugiriApiGatewayStack-${stageConfig.stageName}`,
statsugiriApiGatewayStackProps
);
}
}
new StatsugiriInfrastructureApp().setupBeta().setupProd().synth();