-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
54 lines (48 loc) · 1.56 KB
/
main.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
terraform {
required_providers {
upcloud = {
source = "UpCloudLtd/upcloud"
version = "~> 2.4"
}
}
}
resource "upcloud_loadbalancer" "main" {
configured_status = "started"
name = var.name
plan = var.plan
zone = var.zone
network = var.network
}
resource "upcloud_loadbalancer_backend" "main" {
loadbalancer = upcloud_loadbalancer.main.id
name = "main"
}
resource "upcloud_loadbalancer_static_backend_member" "main" {
count = length(var.backend_servers)
backend = upcloud_loadbalancer_backend.main.id
name = "member_${count.index}"
ip = var.backend_servers[count.index]
port = var.backend_server_port
max_sessions = var.max_server_sessions
enabled = true
weight = 100
}
resource "upcloud_loadbalancer_frontend" "main" {
loadbalancer = upcloud_loadbalancer.main.id
name = "main"
mode = "http"
port = var.frontend_port
default_backend_name = upcloud_loadbalancer_backend.main.name
}
resource "upcloud_loadbalancer_dynamic_certificate_bundle" "main" {
count = length(var.domains) > 0 ? 1 : 0
name = "main"
hostnames = var.domains
key_type = "rsa"
}
resource "upcloud_loadbalancer_frontend_tls_config" "main" {
count = length(var.domains) > 0 ? 1 : 0
frontend = upcloud_loadbalancer_frontend.main.id
name = "main"
certificate_bundle = upcloud_loadbalancer_dynamic_certificate_bundle.main[count.index].id
}