-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinterface.tf
27 lines (22 loc) · 911 Bytes
/
interface.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
resource "routeros_interface_wireguard" "wg" {
name = var.interface_name
listen_port = var.interface_port
}
resource "routeros_ip_address" "ipv4" {
for_each = var.interface_address_ipv4 != null ? toset([var.interface_address_ipv4]) : toset([])
address = each.value
interface = routeros_interface_wireguard.wg.name
}
resource "routeros_ipv6_address" "ipv6" {
for_each = var.interface_address_ipv6 != null ? toset([var.interface_address_ipv6]) : toset([])
address = each.value
interface = routeros_interface_wireguard.wg.name
}
resource "routeros_interface_wireguard_peer" "peer" {
for_each = { for peer in var.peers : peer.public_key => peer }
public_key = each.key
endpoint_address = each.value.endpoint_host
endpoint_port = each.value.endpoint_port
allowed_address = each.value.allowed_addresses
interface = routeros_interface_wireguard.wg.name
}