-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-parent-infra-stack.js
More file actions
67 lines (62 loc) · 1.71 KB
/
deploy-parent-infra-stack.js
File metadata and controls
67 lines (62 loc) · 1.71 KB
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
import cdk from 'aws-cdk-lib'
import budgets from 'aws-cdk-lib/aws-budgets'
import iam from 'aws-cdk-lib/aws-iam'
import {applyStandardTags} from '@tstibbs/cloud-core-utils'
import {buildAccountMonitoring} from './deploy-parent-monitoring.js'
import {buildTooling} from './deploy-parent-tooling.js'
import {buildNotificationChannels} from './deploy-utils.js'
import {WARNING_BUDGET} from './deploy-envs.js'
class ParentAccountInfraStack extends cdk.Stack {
constructor(scope, id, props) {
super(scope, id, props)
const notificationTopic = buildNotificationChannels(this)
buildAccountMonitoring(this, notificationTopic)
buildTooling(this, notificationTopic)
this.createBudgets(this, notificationTopic)
applyStandardTags(this)
}
createBudgets(stack, notificationTopic) {
new budgets.CfnBudget(stack, 'OrganisationBudget', {
budget: {
budgetType: 'COST',
timeUnit: 'MONTHLY',
budgetLimit: {
amount: Number.parseFloat(WARNING_BUDGET),
unit: 'USD'
}
},
notificationsWithSubscribers: [
{
notification: {
notificationType: 'ACTUAL',
comparisonOperator: 'GREATER_THAN',
thresholdType: 'PERCENTAGE',
threshold: 5
},
subscribers: [
{
subscriptionType: 'SNS',
address: notificationTopic.topicArn
}
]
},
{
notification: {
notificationType: 'ACTUAL',
comparisonOperator: 'GREATER_THAN',
thresholdType: 'PERCENTAGE',
threshold: 100
},
subscribers: [
{
subscriptionType: 'SNS',
address: notificationTopic.topicArn
}
]
}
]
})
notificationTopic.grantPublish(new iam.ServicePrincipal('budgets.amazonaws.com'))
}
}
export {ParentAccountInfraStack}