46 lines
1.4 KiB
HCL
46 lines
1.4 KiB
HCL
resource "hcloud_ssh_key" "automation" {
|
|
name = "${var.name}-automation"
|
|
public_key = var.ssh_public_key
|
|
}
|
|
|
|
resource "hcloud_network" "trading_system" {
|
|
name = "${var.name}-network"
|
|
ip_range = var.network_cidr
|
|
}
|
|
|
|
resource "hcloud_network_subnet" "trading_system" {
|
|
network_id = hcloud_network.trading_system.id
|
|
type = "cloud"
|
|
network_zone = var.network_zone
|
|
ip_range = var.subnet_cidr
|
|
}
|
|
|
|
resource "hcloud_server" "trading_system" {
|
|
name = var.name
|
|
image = var.image
|
|
server_type = var.server_type
|
|
location = var.location
|
|
ssh_keys = [hcloud_ssh_key.automation.id]
|
|
firewall_ids = [hcloud_firewall.trading_system.id]
|
|
|
|
public_net {
|
|
ipv4_enabled = true
|
|
ipv6_enabled = true
|
|
}
|
|
|
|
network {
|
|
network_id = hcloud_network.trading_system.id
|
|
ip = var.private_ipv4_address
|
|
}
|
|
|
|
user_data = templatefile("${path.module}/cloud-init.yaml.tftpl", {
|
|
k3s_channel = var.k3s_channel
|
|
node_name = var.name
|
|
private_ipv4_address = var.private_ipv4_address
|
|
public_domain = var.public_domain
|
|
bootstrap_repo_path = var.bootstrap_repo_path
|
|
tailscale_enabled = var.tailscale_enabled
|
|
tailscale_auth_key = var.tailscale_auth_key
|
|
tailscale_control_plane_hostname = var.tailscale_control_plane_hostname
|
|
})
|
|
}
|