36 lines
758 B
HCL
36 lines
758 B
HCL
resource "hcloud_ssh_key" "key" {
|
|
name = "kthw-key"
|
|
public_key = file(var.public_key_file)
|
|
}
|
|
|
|
resource "hcloud_network" "net" {
|
|
name = "kthw-net"
|
|
ip_range = "10.0.0.0/8"
|
|
}
|
|
|
|
resource "hcloud_network_subnet" "subnet" {
|
|
type = "cloud"
|
|
network_id = hcloud_network.net.id
|
|
network_zone = "eu-central"
|
|
ip_range = "10.0.0.0/16"
|
|
}
|
|
|
|
resource "hcloud_server" "boxes" {
|
|
for_each = var.boxes
|
|
name = "kthw-${each.key}"
|
|
image = "debian-12"
|
|
ssh_keys = [hcloud_ssh_key.key.id]
|
|
server_type = "cx23"
|
|
|
|
network {
|
|
network_id = hcloud_network.net.id
|
|
ip = each.value.private_ip
|
|
}
|
|
|
|
public_net {
|
|
ipv4_enabled = true
|
|
ipv6_enabled = false
|
|
}
|
|
|
|
depends_on = [ hcloud_network_subnet.subnet ]
|
|
} |