forked from conorcolgan/quickstart-aws-biotech-blueprint-cdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApplyCfnLintExceptions.py
45 lines (33 loc) · 2.32 KB
/
ApplyCfnLintExceptions.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
import os
import yaml
templateStream = open('./templates/AwsBiotechBlueprint.template.yml', 'r')
templateData = yaml.safe_load(templateStream)
paremeterToPop = ''
for parameter in templateData['Parameters']:
if templateData['Parameters'][parameter]['Description'].startswith( 'Artifact hash for asset'):
paremeterToPop = parameter
if paremeterToPop != '': templateData['Parameters'].pop(paremeterToPop)
for resource in templateData['Resources']:
if templateData['Resources'][resource]['Metadata']['aws:cdk:path'] == 'AwsBiotechBlueprint/ClientVpn/VpnCertificateLambdaCustomResourceRole/DefaultPolicy/Resource' \
or templateData['Resources'][resource]['Metadata']['aws:cdk:path'] == 'AwsBiotechBlueprint/VpcCore/retentionRole/DefaultPolicy/Resource' :
templateData['Resources'][resource]['Metadata']['cfn-lint'] = {
"config": {
"ignore_checks": ['EIAMPolicyWildcardResource', 'EIAMPolicyActionWildcard'],
"ignore_reasons": {
"EIAMPolicyWildcardResource": "This particular role gives permission to a custom resource to create a certificate. We cannot provide a specific certificate ARN at deployment time as it does not yet exist."
, "EIAMPolicyActionWildcard": "The policy action wildcards in this policy are generated by the AWS CDK, which the developers of this Quick Start have no control over."
}
}
}
if templateData['Resources'][resource]['Metadata']['aws:cdk:path'] == 'AwsBiotechBlueprint/ConfigPacks/CP-Operational-Best-Practices-for-HIPAA-Security' \
or templateData['Resources'][resource]['Metadata']['aws:cdk:path'] == 'AwsBiotechBlueprint/ConfigPacks/CP-Operational-Best-Practices-for-NIST-CSF':
templateData['Resources'][resource]['Metadata']['cfn-lint'] = {
"config": {
"ignore_checks": ['E9101'],
"ignore_reasons": {
"E9101": "The references to master in this resource refer to EMR service naming. Until the EMR service changes its usage of the term, this needs to be an exception.",
}
}
}
with open('./templates/AwsBiotechBlueprint.template.yml', 'w') as json_file:
yaml.dump(templateData, json_file, indent=2)