-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhyperfetch.tf
More file actions
77 lines (67 loc) · 2.14 KB
/
Copy pathhyperfetch.tf
File metadata and controls
77 lines (67 loc) · 2.14 KB
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
resource "cloudflare_zone" "hyperfetch" {
account_id = local.cf_account_id
zone = "hyperfetch.net"
plan = "free"
}
module "hyperfetch_repository" {
source = "./modules/github-repository"
name = "hyperfetch"
description = "Just type hyperfetch.net/ in front of any URL to fetch"
homepage_url = "https://${cloudflare_record.hyperfetch_howto.hostname}"
}
resource "cloudflare_record" "hyperfetch" {
zone_id = cloudflare_zone.hyperfetch.id
name = "@"
type = "A"
value = "192.0.2.1"
proxied = true
}
resource "cloudflare_record" "hyperfetch_www" {
zone_id = cloudflare_zone.hyperfetch.id
name = "www"
type = "CNAME"
value = cloudflare_record.hyperfetch.hostname
proxied = true
}
resource "cloudflare_page_rule" "redirect_hyperfetch_www" {
zone_id = cloudflare_zone.hyperfetch.id
target = "${cloudflare_record.hyperfetch_www.hostname}/*"
actions {
forwarding_url {
url = "http://${cloudflare_record.hyperfetch.hostname}/$1"
status_code = 301
}
}
}
resource "cloudflare_pages_project" "hyperfetch" {
account_id = local.cf_account_id
name = "hyperfetch"
production_branch = "main"
}
resource "cloudflare_record" "hyperfetch_howto" {
zone_id = cloudflare_zone.hyperfetch.id
name = "howto"
type = "CNAME"
value = cloudflare_pages_project.hyperfetch.subdomain
proxied = true
}
resource "cloudflare_pages_domain" "hyperfetch" {
account_id = local.cf_account_id
project_name = cloudflare_pages_project.hyperfetch.name
domain = cloudflare_record.hyperfetch_howto.hostname
}
resource "github_actions_secret" "cf_token" {
repository = module.hyperfetch_repository.name
secret_name = "CF_API_TOKEN"
plaintext_value = var.gh_secret_cf_token
}
resource "github_actions_secret" "cf_account_id" {
repository = module.hyperfetch_repository.name
secret_name = "CF_ACCOUNT_ID"
plaintext_value = local.cf_account_id
}
resource "cloudflare_worker_route" "hyperfetch" {
zone_id = cloudflare_zone.hyperfetch.id
pattern = "${cloudflare_record.hyperfetch.hostname}/*"
script_name = "hyperfetch"
}