-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmaster.tf
More file actions
45 lines (41 loc) · 1.47 KB
/
Copy pathmaster.tf
File metadata and controls
45 lines (41 loc) · 1.47 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
### Server creation with one linked primary ip (ipv4)
resource "hcloud_primary_ip" "master_node_public_ip" {
name = "primary_ip_test"
datacenter = "fsn1-dc14"
type = "ipv4"
assignee_type = "server"
auto_delete = true
}
data "template_file" "master-node-config" {
template = file("${path.module}/cloud-init.yaml")
vars = {
local_ssh_public_key = file("${path.module}/.ssh/local_rsa.pub")
worker_ssh_public_key = tls_private_key.worker-ssh-key.public_key_openssh
hcloud_token = var.hcloud_token
hcloud_network = hcloud_network.private_network.id
public_ip = tostring(hcloud_primary_ip.master_node_public_ip.ip_address)
}
}
resource "hcloud_server" "master-node" {
name = "master-node"
image = "ubuntu-24.04"
server_type = "cx22"
location = "fsn1"
public_net {
ipv4 = hcloud_primary_ip.master_node_public_ip.id
ipv4_enabled = true
ipv6_enabled = true
}
network {
network_id = hcloud_network.private_network.id
# IP Used by the master node, needs to be static
# Here the worker nodes will use 10.0.1.1 to communicate with the master node
ip = "10.0.1.1"
}
# If we don't specify this, Terraform will create the resources in parallel
# We want this node to be created after the private network is created
depends_on = [hcloud_network_subnet.private_network_subnet]
}
output "master_node_public_ip" {
value = tostring(hcloud_primary_ip.master_node_public_ip.ip_address)
}