-
Notifications
You must be signed in to change notification settings - Fork 28
/
main.tf
37 lines (33 loc) · 1.02 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
resource "cloudflare_worker_script" "this" {
account_id = var.account_id
name = format("maintenance-%s", replace(var.cloudflare_zone, ".", "-"))
content = templatefile("${path.module}/maintenance.js", {
company_name = var.company_name
logo_url = var.logo_url
favicon_url = var.favicon_url
font = var.font
email = var.email
statuspage_url = var.statuspage_url
google_font = replace(var.font, " ", "+")
})
plain_text_binding {
name = "WHITELIST_IPS"
text = var.whitelist_ips
}
plain_text_binding {
name = "WHITELIST_PATH"
text = var.whitelist_path
}
}
data "cloudflare_zones" "this" {
filter {
account_id = var.account_id
name = var.cloudflare_zone
}
}
resource "cloudflare_worker_route" "this" {
count = var.enabled != false ? length(var.patterns) : 0
zone_id = lookup(data.cloudflare_zones.this.zones[0], "id")
pattern = var.patterns[count.index]
script_name = cloudflare_worker_script.this.name
}