-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
77 lines (67 loc) · 1.99 KB
/
main.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
77
locals {
category_settings = {
"1" = [
{ category = "paranoia-level-2", enabled = false },
{ category = "paranoia-level-3", enabled = false },
{ category = "paranoia-level-4", enabled = false }
],
"2" = [
{ category = "paranoia-level-3", enabled = false },
{ category = "paranoia-level-4", enabled = false }
],
"3" = [
{ category = "paranoia-level-4", enabled = false }
],
"4" = []
}
}
data "cloudflare_zones" "zones" {
count = length(var.domains)
filter {
name = var.domains[count.index]
lookup_type = "exact"
paused = false
}
}
resource "cloudflare_ruleset" "zone_level_managed_waf" {
count = length(var.domains)
zone_id = lookup(data.cloudflare_zones.zones[count.index].zones[0], "id")
name = "Cloudflare Managed Ruleset"
description = "Zone-level WAF Managed Rules config"
kind = "zone"
phase = "http_request_firewall_managed"
# Managed Ruleset
rules {
action = "execute"
action_parameters {
id = "efb7b8c949ac4650a09736fc376e9aee"
}
expression = "true"
description = "Execute Cloudflare Managed Ruleset on my zone-level phase entry point ruleset"
enabled = var.managed_ruleset_enabled
}
# OWASP Core Ruleset
rules {
action = "execute"
action_parameters {
id = "4814384a9e5d4991b9815dcfc25d2f1f"
overrides {
dynamic "categories" {
for_each = local.category_settings[tostring(var.paranoia_level)]
content {
category = categories.value.category
enabled = categories.value.enabled
}
}
rules {
id = "6179ae15870a4bb7b2d480d4843b323c"
action = var.owasp_action
score_threshold = var.anomaly_score_threshold
}
}
}
expression = "true"
description = "Execute Cloudflare Managed Ruleset on my zone-level phase entry point ruleset"
enabled = var.owasp_enabled
}
}