-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.ts
54 lines (47 loc) · 1.38 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
import { App, Stack } from 'aws-cdk-lib'
import { Api } from './api/cdk'
import { DynamoTable } from './database/cdk'
import { Monitoring } from './monitoring/cdk'
import { DeploymentPipeline } from './pipeline/cdk'
import { getAwsAccount, getAwsRegion } from './utils'
const app = new App() // CDK App
// Get AWS account and region
const awsEnv = { account: getAwsAccount(), region: getAwsRegion() }
// Props
const appName = 'Python-Serverless-API'
const tableName = `${appName}-Table`
// Dynamo Table Stack
const tableStack = new Stack(app, `${tableName}-Stack`, {
description: 'Table Stack',
env: awsEnv
})
new DynamoTable(tableStack, 'Table', {
tableName
})
// Http Api
const httpApiStack = new Stack(app, `${appName}-Stack`, {
description: 'API Stack',
env: awsEnv
})
new Api(httpApiStack, 'Api', {
apiName: appName,
tableName
})
// Monitoring Stack
const monitoringStack = new Stack(app, `${appName}-Monitoring-Stack`, {
description: 'Monitoring Stack',
env: awsEnv
})
monitoringStack.addDependency(httpApiStack)
new Monitoring(monitoringStack, 'Monitoring', {
tableName,
apiName: appName
})
// Define Deployment Pipeline
new DeploymentPipeline(app, `${appName}-Pipeline-Stack`, {
awsEnv,
repoOwner: 'sudopla',
repoName: 'python-serverless-api',
pipelineName: `${appName}-Pipeline`,
stackNames: [`${tableName}-Stack`, `${appName}-Stack`, `${appName}-Monitoring-Stack`]
})