-
Notifications
You must be signed in to change notification settings - Fork 1
/
outputs.tf
67 lines (55 loc) · 1.59 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
# ===================================
# Manage volumes in the Hetzner Cloud
# ===================================
# ------------
# Local Values
# ------------
locals {
output_volumes = [
for name, volume in hcloud_volume.volumes : merge(volume, {
"attachment" = try(hcloud_volume_attachment.attachments[name], {})
})
]
output_attachments = [
for name, attachment in hcloud_volume_attachment.attachments :
merge(attachment, {
"name" = name
"volume_name" = try(local.attachments[name].volume, null)
})
]
}
# -------------
# Output Values
# -------------
output "volumes" {
description = "A list of all volume objects."
value = local.output_volumes
}
output "volume_ids" {
description = "A map of all volume objects indexed by ID."
value = {
for volume in local.output_volumes : volume.id => volume
}
}
output "volume_names" {
description = "A map of all volume objects indexed by name."
value = {
for volume in local.output_volumes : volume.name => volume
}
}
output "volume_attachments" {
description = "A list of all volume attachment objects."
value = local.output_attachments
}
output "volume_attachment_ids" {
description = "A map of all volume attachment objects indexed by ID."
value = {
for attachment in local.output_attachments : attachment.id => attachment
}
}
output "volume_attachment_names" {
description = "A map of all volume attachment objects indexed by name."
value = {
for attachment in local.output_attachments : attachment.name => attachment
}
}