-
Notifications
You must be signed in to change notification settings - Fork 1
/
outputs.tf
100 lines (84 loc) · 2.36 KB
/
outputs.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# ===================================
# Manage servers in the Hetzner Cloud
# ===================================
# ------------
# Local Values
# ------------
locals {
output_servers = [
for name, server in hcloud_server.servers : merge(server, {
"network" = null,
"networks" = [
for network in hcloud_server_network.networks : network
if(tostring(network.server_id) == server.id)
],
"rdns" = [
for rdns in hcloud_rdns.server_rdns : rdns
if(tostring(rdns.server_id) == server.id)
]
})
]
output_rdns = [
for name, rdns in hcloud_rdns.server_rdns : merge(rdns, {
"name" = name
"server_name" = try(local.rdns[name].server, null)
})
]
output_networks = [
for name, network in hcloud_server_network.networks : merge(network, {
"name" = name
"server_name" = try(local.networks[name].server, null)
})
]
}
# -------------
# Output Values
# -------------
output "servers" {
description = "A list of all server objects."
value = local.output_servers
}
output "server_ids" {
description = "A map of all server objects indexed by ID."
value = {
for server in local.output_servers : server.id => server
}
}
output "server_names" {
description = "A map of all server objects indexed by name."
value = {
for server in local.output_servers : server.name => server
}
}
output "server_rdns" {
description = "A list of all server RDNS objects."
value = local.output_rdns
}
output "server_rdns_ids" {
description = "A map of all server RDNS objects indexed by ID."
value = {
for rdns in local.output_rdns : rdns.id => rdns
}
}
output "server_rdns_names" {
description = "A map of all server RDNS objects indexed by name."
value = {
for rdns in local.output_rdns : rdns.name => rdns
}
}
output "server_networks" {
description = "A list of all server network objects."
value = local.output_networks
}
output "server_network_ids" {
description = "A map of all server network objects indexed by ID."
value = {
for network in local.output_networks : network.id => network
}
}
output "server_network_names" {
description = "A map of all server network objects indexed by name."
value = {
for network in local.output_networks : network.name => network
}
}