-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfirewall-cloudfront.tf
76 lines (61 loc) · 1.68 KB
/
firewall-cloudfront.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
resource "aws_waf_ipset" "ipset" {
count = var.create_firewall ? 1 : 0
name = "researchhub_cloudfront_ipset_${var.lifecycle_state}"
# the list of IPs we want to whitelist = UoA IP ranges only
## https://wiki.auckland.ac.nz/pages/viewpage.action?pageId=143067942
ip_set_descriptors {
type = "IPV4"
value = "130.216.0.0/16" # uoa network ip range
}
ip_set_descriptors {
type = "IPV4"
value = "172.24.0.0/18" # uoa wifi internal ip range
}
ip_set_descriptors {
type = "IPV4"
value = "202.36.244.0/24" #uoa wifi external ip range
}
ip_set_descriptors {
type = "IPV4"
value = "10.0.0.0/8" # uoa wifi ip range
}
ip_set_descriptors {
type = "IPV4"
value = "192.168.0.0/16" # uoa wifi ip range
}
ip_set_descriptors {
type = "IPV4"
value = "10.110.0.0/24" # vpn internal range
}
}
resource "aws_waf_rule" "wafrule" {
count = var.create_firewall ? 1 : 0
depends_on = [aws_waf_ipset.ipset[0]]
name = "researchhub_cloudfront_waf_rule_${var.lifecycle_state}"
metric_name = "researchhubcloudfrontwafrule${var.lifecycle_state}"
predicates {
data_id = aws_waf_ipset.ipset[0].id
negated = false
type = "IPMatch"
}
}
resource "aws_waf_web_acl" "waf_acl" {
count = var.create_firewall ? 1 : 0
depends_on = [
aws_waf_ipset.ipset[0],
aws_waf_rule.wafrule[0],
]
name = "researchhub_cloudfront_waf_acl_${var.lifecycle_state}"
metric_name = "researchhubcloudfrontwafacl${var.lifecycle_state}"
default_action {
type = "BLOCK"
}
rules {
action {
type = "ALLOW"
}
priority = 1
rule_id = aws_waf_rule.wafrule[0].id
type = "REGULAR"
}
}