forked from zerotier/terraform-zerotier-network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
62 lines (53 loc) · 1.26 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
locals {
assignment_pools = flatten([
for subnet in var.subnets : [{
start = cidrhost(subnet, min(range(32 - split("/", subnet)[1])...) + 1)
end = cidrhost(subnet, pow(2, (32 - split("/", subnet)[1])) - 1)
}]
])
}
locals {
routes = var.routes
}
locals {
subnet_routes = flatten([
for subnet in var.subnets : [{
target = subnet
via = null
}]
])
}
resource "zerotier_network" "this" {
name = var.name
description = var.description
enable_broadcast = var.enable_broadcast
flow_rules = var.flow_rules
multicast_limit = var.multicast_limit
private = var.private
assign_ipv4 {
zerotier = var.assign_ipv4.zerotier
}
assign_ipv6 {
zerotier = var.assign_ipv6.zerotier
sixplane = var.assign_ipv6.sixplane
rfc4193 = var.assign_ipv6.rfc4193
}
dynamic "assignment_pool" {
for_each = local.assignment_pools
content {
start = assignment_pool.value.start
end = assignment_pool.value.end
}
}
dynamic "route" {
for_each = flatten(concat(local.routes, local.subnet_routes))
content {
target = route.value.target
via = route.value.via
}
}
dns {
domain = var.dns.domain
servers = var.dns.servers
}
}