-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathlocals.tf
40 lines (30 loc) · 1.3 KB
/
locals.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
# Copyright 2019, 2021 Oracle Corporation and/or affiliates. All rights reserved.
# Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
# Protocols are specified as protocol numbers.
# https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
locals {
all_protocols = "all"
anywhere = "0.0.0.0/0"
wireguard_template = "${path.module}/cloudinit/wireguard.template.yaml"
wireguard_image_id = data.oci_core_images.oracle_images.images.0.id
# port numbers
ssh_port = 22
wireguard_port = 51820
# protocols
tcp_protocol = 6
udp_protocol = 17
# we expect the wireguard to be in the first cidr block in the list of cidr blocks
vcn_cidr = element(data.oci_core_vcn.vcn.cidr_blocks, 0)
setup_wireguard_template = base64gzip(
templatefile("${path.module}/scripts/wireguard.template.sh", {}
)
)
wireguard_conf_template = base64gzip(
templatefile("${path.module}/conf/wg.template.conf", {}
)
)
peer_publickey = "PublicKey="
peer_allowed_ips = join("", ["AllowedIPs=", local.vcn_cidr])
peer_endpoint = join(",", ["Endpoint=${data.oci_core_vnic.wireguard_vnic.public_ip_address}:51820"])
peer_conf = join("\n", ["[Peer]", local.peer_publickey, local.peer_allowed_ips, local.peer_endpoint])
}