-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
71 lines (65 loc) · 2.09 KB
/
app.py
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
#!/usr/bin/env python3
import aws_cdk as cdk
from os import getenv
from infra.usage_anomaly_detector import UsageAnomalyDetectorStack
from cdk_nag import AwsSolutionsChecks, NagSuppressions, NagPackSuppression
app = cdk.App()
usage_anomaly_detector_infra_stack = UsageAnomalyDetectorStack(app, app.node.try_get_context('stack-name'),
env=cdk.Environment(
region=getenv('AWS_REGION', getenv('CDK_DEFAULT_REGION')),
account=getenv('AWS_ACCOUNT_ID', getenv('CDK_DEFAULT_ACCOUNT'))
),
description="Usage Anomaly Detector Stack (uksb-1tupbocl1) "
)
tags={
'SolutionName': 'Usage Anomaly Detector',
'SolutionVersion': 'v1.0.0',
'SolutionIaC': 'CDK v2'
}
for key, val in tags.items():
cdk.Tags.of(usage_anomaly_detector_infra_stack).add(key,val)
# nag suppressions
nagsuppression_checks = [
{
"rule":"AwsSolutions-L1",
"reason":"Already using latest version pythnb3.9 & nodejs18.x for lambda"
},
{
"rule":"AwsSolutions-IAM4",
"reason": "use AWS managed policies for IAM roles for lambda & other cdk defaults"
},
{
"rule":"AwsSolutions-IAM5",
"reason":"use AWS managed policies from cdk defaults"
},
{
"rule" : "AwsSolutions-OS1",
"reason" : "using public opensearch domain for solution"
},
{
"rule" : "AwsSolutions-OS3",
"reason" : "using public opensearch domain for solution, IP restriction can be added by oss user."
},
{
"rule" : "AwsSolutions-OS4",
"reason" : "does not need dedicated master"
},
{
"rule": "AwsSolutions-OS5",
"reason": "using cognito for public opensearch dashboard auth"
},
{
"rule": "AwsSolutions-OS9",
"reason": "solution dedicated opensearch, exempting slow logs/index publish"
}
]
for checks in nagsuppression_checks:
NagSuppressions.add_stack_suppressions(usage_anomaly_detector_infra_stack, [
NagPackSuppression(
id=checks['rule'],
reason=checks['reason']
)
])
# nag checks
cdk.Aspects.of(app).add(AwsSolutionsChecks(verbose=True))
app.synth()