-
Notifications
You must be signed in to change notification settings - Fork 0
/
cloudflare.tf
40 lines (36 loc) · 1018 Bytes
/
cloudflare.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
resource "random_password" "tunnel_secret" {
length = 64
}
resource "random_string" "suffix" {
length = 16
special = false
upper = false
}
resource "cloudflare_tunnel" "tunnel" {
account_id = var.cloudflare_account_id
name = "${var.prefix}-tunnel-${random_string.suffix.result}"
secret = base64encode(random_password.tunnel_secret.result)
}
resource "cloudflare_tunnel_route" "route" {
account_id = var.cloudflare_account_id
tunnel_id = cloudflare_tunnel.tunnel.id
network = data.aws_vpc.vpc.cidr_block
comment = "Tunnel route for ${var.vpc_id}"
}
resource "cloudflare_tunnel_config" "config" {
account_id = var.cloudflare_account_id
tunnel_id = cloudflare_tunnel.tunnel.id
config {
warp_routing {
enabled = true
}
dynamic "ingress_rule" {
for_each = var.ingress_rules
content {
hostname = ingress_rule.value.hostname
path = ingress_rule.value.path
service = ingress_rule.value.service
}
}
}
}