-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.tf
More file actions
70 lines (61 loc) · 1.78 KB
/
main.tf
File metadata and controls
70 lines (61 loc) · 1.78 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
terraform {
required_providers {
upcloud = {
source = "UpCloudLtd/upcloud"
version = "~> 5.23"
}
}
}
resource "upcloud_loadbalancer" "main" {
configured_status = "started"
name = var.name
plan = var.plan
zone = var.zone
networks {
name = "public"
family = "IPv4"
type = "public"
}
networks {
name = "private"
family = "IPv4"
network = var.network
type = "private"
}
}
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
networks {
name = upcloud_loadbalancer.main.networks[0].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
}