@@ -8,3 +8,96 @@ resource "aws_cloudwatch_log_group" "api_gateway" {
88 prevent_destroy = false
99 }
1010}
11+
12+ resource "aws_cloudwatch_log_data_protection_policy" "api_gateway_data_protection" {
13+ log_group_name = aws_cloudwatch_log_group. api_gateway . name
14+ policy_document = jsonencode ({
15+ Name = " data-protection-policy"
16+ Version = " 2021-06-01"
17+ Statement = [
18+ {
19+ Sid = " MaskSensitiveData"
20+ Effect = " Deny"
21+ Principal = { " AWS" : " *" }
22+ Action = " cloudwatch:PutLogEvents"
23+ Resource = " *"
24+ DataIdentifier = [
25+ " arn:aws:dataprotection::aws:data-identifier/DateOfBirth" ,
26+ " arn:aws:dataprotection::aws:data-identifier/UkPostcode" ,
27+ " arn:aws:dataprotection::aws:data-identifier/Custom:UkPostcodeSector" ,
28+ " arn:aws:dataprotection::aws:data-identifier/Custom:GpPracticeCode" ,
29+ " arn:aws:dataprotection::aws:data-identifier/Custom:13QFlag" ,
30+ " arn:aws:dataprotection::aws:data-identifier/Custom:CareHomeFlag" ,
31+ " arn:aws:dataprotection::aws:data-identifier/Custom:DEFlag" ,
32+ " arn:aws:dataprotection::aws:data-identifier/Custom:RemovalReasonCode" ,
33+ " arn:aws:dataprotection::aws:data-identifier/Custom:ValidDosesCount" ,
34+ " arn:aws:dataprotection::aws:data-identifier/Custom:InvalidDosesCount" ,
35+ " arn:aws:dataprotection::aws:data-identifier/Custom:LastSuccessfulDate" ,
36+ " arn:aws:dataprotection::aws:data-identifier/Custom:LastValidDoseDate" ,
37+ " arn:aws:dataprotection::aws:data-identifier/Custom:CohortLabel"
38+
39+ ]
40+ Operation = {
41+ " cloudwatch:Mask" = {}
42+ }
43+ },
44+ ]
45+ CustomDataIdentifier = [
46+ {
47+ Name = " UkPostcodeSector"
48+ Regex = " [A-Z]{1,2}[0-9R-9][0A-Z]? ?[0-9]"
49+ Severity = " High"
50+ },
51+ {
52+ Name = " GpPracticeCode"
53+ Regex = " GP_PRACTICE[\\ s\\\" ':=]*([A-Z][0-9]{5})"
54+ Severity = " High"
55+ },
56+ {
57+ Name = " 13QFlag"
58+ Regex = " 13Q_FLAG[\\ s\\\" ':=]*[YN]"
59+ Severity = " High"
60+ },
61+ {
62+ Name = " CareHomeFlag"
63+ Regex = " CARE_HOME_FLAG[\\ s\\\" ':=]*[YN]"
64+ Severity = " High"
65+ },
66+ {
67+ Name = " DEFlag"
68+ Regex = " DE_FLAG[\\ s\\\" ':=]*[YN]"
69+ Severity = " High"
70+ },
71+ {
72+ Name = " RemovalReasonCode"
73+ Regex = " REMOVAL_REASON_CODE[\\ s\\\" ':=]*([A-Z]{3})"
74+ Severity = " High"
75+ },
76+ {
77+ Name = " ValidDosesCount"
78+ Regex = " VALID_DOSES_COUNT[\\ s\\\" ':=]*([0-9]{1,2}|100)"
79+ Severity = " High"
80+ },
81+ {
82+ Name = " InvalidDosesCount"
83+ Regex = " INVALID_DOSES_COUNT[\\ s\\\" ':=]*([0-9]{1,2}|100)"
84+ Severity = " High"
85+ },
86+ {
87+ Name = " LastSuccessfulDate"
88+ Regex = " LAST_SUCCESSFUL_DATE[\\ s\\\" ':=]*([0-9]{8})"
89+ Severity = " High"
90+ },
91+ {
92+ Name = " LastValidDoseDate"
93+ Regex = " LAST_VALID_DOSE_DATE[\\ s\\\" ':=]*([0-9]{8})"
94+ Severity = " High"
95+ },
96+ {
97+ Name = " CohortLabel"
98+ Regex = " COHORT_LABEL[\\ s\\\" ':=]*([A-Za-z0-9_ -]{1,100})"
99+ Severity = " High"
100+ }
101+ ]
102+ })
103+ }
0 commit comments