40 lines
852 B
Terraform
Raw Normal View History

2023-09-12 21:20:24 +02:00
resource "hcloud_server" "lb" {
name = "LB"
image = "ubuntu-22.04"
server_type = "cx21"
location = var.location
labels = {
app = "lb"
}
2023-09-12 21:20:24 +02:00
ssh_keys = var.ssh_key_ids
2023-09-12 21:20:24 +02:00
public_net {
ipv4_enabled = true
ipv6_enabled = false
}
network {
network_id = var.network_id
ip = var.lb_internal_ip
}
}
resource "hcloud_load_balancer_target" "main" {
2023-09-12 21:20:24 +02:00
type = "server"
load_balancer_id = var.lb_service_id
use_private_ip = true
2023-09-12 21:20:24 +02:00
server_id = hcloud_server.lb.id
}
resource "hcloud_load_balancer_network" "main" {
load_balancer_id = var.lb_service_id
network_id = var.network_id
}
2023-09-12 21:20:24 +02:00
resource "hcloud_load_balancer_service" "load_balancer_service" {
load_balancer_id = var.lb_service_id
protocol = "tcp"
listen_port = 443
destination_port = 443
}