generated from particuleio/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
78 lines (60 loc) · 2.72 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
resource "scaleway_lb_ip" "this" {
for_each = {
for loadbalancer, config in local.loadbalancers :
loadbalancer => config
if config.create_ip
}
}
resource "scaleway_lb" "this" {
for_each = local.loadbalancers
ip_id = each.value.create_ip ? scaleway_lb_ip.this[each.key].id : data.scaleway_lb_ip.this[each.key].id
name = lookup(each.value, "name", null)
type = upper(each.value["type"])
zone = lookup(each.value, "zone", null)
project_id = lookup(each.value, "project_id", null)
tags = each.value.tags
}
resource "scaleway_lb_backend" "this" {
for_each = {
for backend in local.backends : "${backend.loadbalancer}_${backend.name}" => backend
}
lb_id = scaleway_lb.this[each.value.loadbalancer].id
name = each.value.name
forward_protocol = each.value.config.forward_protocol
forward_port = each.value.config.forward_port
forward_port_algorithm = lookup(each.value.config, "forward_port_algorithm", "roundrobin")
sticky_sessions = lookup(each.value.config, "sticky_session", "none")
sticky_sessions_cookie_name = lookup(each.value.config, "sticky_session_cookie_name", null)
server_ips = lookup(each.value.config, "server_ips", [])
proxy_protocol = lookup(each.value.config, "proxy_protocol", "none")
timeout_server = lookup(each.value.config, "timeout_server", null)
timeout_connect = lookup(each.value.config, "timeout_connect", null)
timeout_tunnel = lookup(each.value.config, "timeout_tunnel", null)
# TODO: Add Healthcheck support
}
resource "scaleway_lb_frontend" "this" {
for_each = {
for frontend in local.frontends : "${frontend.loadbalancer}_${frontend.name}" => frontend
}
lb_id = scaleway_lb.this[each.value.loadbalancer].id
backend_id = scaleway_lb_backend.this["${each.value.loadbalancer}_${each.value.config.backend_name}"].id
name = each.value.name
inbound_port = each.value.config.inbound_port
timeout_client = lookup(each.value.config, "timeout_client", null)
# NOTE: Ensure this property is working as expected when setting up a LB with certificate support
certificate_id = lookup(each.value.config, "certificate_name", null) != null ? scaleway_lb_certificate.this["${each.value.loadbalancer}_${each.value.config.certificate_name}"].id : null
dynamic "acl" {
for_each = lookup(each.value.config, "acls", [])
content {
action {
type = acl.value.action_type
}
match {
ip_subnet = lookup(acl.value.match, "ip_subnet", null)
http_filter = lookup(acl.value.match, "http_filter", null)
http_filter_value = lookup(acl.value.match, "http_filter_value", null)
invert = lookup(acl.value.match, "invert", false)
}
}
}
}