-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvariables.tf
62 lines (54 loc) · 1.77 KB
/
variables.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
# ===================================
# Manage volumes in the Hetzner Cloud
# ===================================
# ---------------
# Input Variables
# ---------------
variable "volumes" {
description = "The list of volume objects to be managed. Each volume object supports the following parameters: 'name' (string, required), 'location' (string, required), 'size' (number, required), 'format' (string, optional), 'protection' (bool, optional), 'server' (server object, optional), 'labels' (map of KV pairs, optional). The server object supports the following parameters: 'name' (string, required), 'id' (string, required), 'automount' (bool, optional)."
type = list(
object({
name = string
location = string
size = number
format = string
protection = bool
server = object({
name = string
id = string
automount = bool
})
labels = map(string)
})
)
default = [
{
name = "volume-nbg1-1"
location = "nbg1"
size = 10
automount = false
format = "xfs"
protection = false
server = null
labels = {}
}
]
validation {
condition = can([
for volume in var.volumes : regex("\\w+", volume.name)
])
error_message = "All volumes must have a valid 'name' attribute specified."
}
validation {
condition = can([
for volume in var.volumes : regex("\\w+", volume.location)
])
error_message = "All volumes must have a valid 'location' attribute specified."
}
validation {
condition = can([
for volume in var.volumes : regex("\\d+", volume.size)
])
error_message = "All volumes must have a valid 'size' attribute specified."
}
}