-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaf.tf
56 lines (47 loc) · 1.15 KB
/
waf.tf
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
resource "aws_wafv2_web_acl" "dd4c_waf_acl" {
provider = aws.us-east-1
name = "DD4C-ACL"
scope = "CLOUDFRONT"
default_action {
block {}
}
visibility_config {
cloudwatch_metrics_enabled = false
metric_name = "DD4C-WAF-Stream"
sampled_requests_enabled = true
}
rule {
name = "MustBeViaDomain"
priority = 0
statement {
regex_pattern_set_reference_statement {
arn = aws_wafv2_regex_pattern_set.domain_pattern.arn
field_to_match {
single_header {
name = "host"
}
}
text_transformation {
priority = 0
type = "LOWERCASE"
}
}
}
action {
allow {}
}
visibility_config {
cloudwatch_metrics_enabled = false
metric_name = "restrict-requests-without-correct-host-header"
sampled_requests_enabled = true
}
}
}
resource "aws_wafv2_regex_pattern_set" "domain_pattern" {
provider = aws.us-east-1
name = "DD4C_Domain"
scope = "CLOUDFRONT"
regular_expression {
regex_string = "^dd4c(?:-test)?\\.digital\\.nhs\\.uk$"
}
}