forked from walrus-catalog/terraform-docker-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
185 lines (167 loc) · 4.43 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
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#
# Contextual Fields
#
variable "context" {
description = <<-EOF
Receive contextual information. When Walrus deploys, Walrus will inject specific contextual information into this field.
Examples:
```
context:
project:
name: string
id: string
environment:
name: string
id: string
resource:
name: string
id: string
```
EOF
type = map(any)
default = {}
}
#
# Infrastructure Fields
#
variable "infrastructure" {
description = <<-EOF
Specify the infrastructure information for deploying.
Examples:
```
infrastructure:
network_id: string, optional
domain_suffix: string, optional
```
EOF
type = object({
network_id = optional(string, "local-walrus")
domain_suffix = optional(string, "cluster.local")
})
default = {
network_id = "local-walrus"
domain_suffix = "cluster.local"
}
}
#
# Deployment Fields
#
variable "architecture" {
description = <<-EOF
Specify the deployment architecture, select from standalone or replication.
EOF
type = string
default = "standalone"
validation {
condition = var.architecture == "" || contains(["standalone", "replication"], var.architecture)
error_message = "Invalid architecture"
}
}
variable "replication_readonly_replicas" {
description = <<-EOF
Specify the number of read-only replicas under the replication deployment.
EOF
type = number
default = 1
validation {
condition = var.replication_readonly_replicas == 0 || contains([1, 3, 5], var.replication_readonly_replicas)
error_message = "Invalid number of read-only replicas"
}
}
variable "engine_version" {
description = <<-EOF
Specify the deployment engine version, select from https://hub.docker.com/r/bitnami/postgresql/tags.
EOF
type = string
default = "16.0"
}
variable "database" {
description = <<-EOF
Specify the database name. The database name must be 2-64 characters long and start with any lower letter, combined with number, or symbols: - _.
The database name cannot be PostgreSQL forbidden keyword.
EOF
type = string
default = "mydb"
validation {
condition = var.database == "" || can(regex("^[a-z][-a-z0-9_]{0,61}[a-z0-9]$", var.database))
error_message = format("Invalid database: %s", var.database)
}
}
variable "username" {
description = <<-EOF
Specify the account username. The username must be 2-16 characters long and start with lower letter, combined with number, or symbol: _.
The username cannot be PostgreSQL forbidden keyword and root.
See https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createaccount.
EOF
type = string
default = "rdsuser"
validation {
condition = var.username == "" || can(regex("^[a-z][a-z0-9_]{0,14}[a-z0-9]$", var.username))
error_message = format("Invalid username: %s", var.username)
}
}
variable "password" {
description = <<-EOF
Specify the account password. The password must be 8-32 characters long and start with any letter, number, or symbols: ! # $ % ^ & * ( ) _ + - =.
If not specified, it will use the first 16 characters of the username md5 hash value.
EOF
type = string
default = null
sensitive = true
validation {
condition = var.password == null || var.password == "" || can(regex("^[A-Za-z0-9\\!#\\$%\\^&\\*\\(\\)_\\+\\-=]{8,32}", var.password))
error_message = "Invalid password"
}
}
variable "resources" {
description = <<-EOF
Specify the computing resources.
Examples:
```
resources:
cpu: number, optional
memory: number, optional # in megabyte
```
EOF
type = object({
cpu = optional(number, 0.25)
memory = optional(number, 1024)
})
default = {
cpu = 0.25
memory = 1024
}
}
#
# Seeding Fields
#
variable "seeding" {
description = <<-EOF
Specify the configuration to seed the database at first-time creating.
Seeding increases the startup time waiting and also needs proper permission,
like root account.
Examples:
```
seeding:
type: none/url/text
url:
location: string
text:
content: string
```
EOF
type = object({
type = optional(string, "none")
url = optional(object({
location = string
}))
text = optional(object({
content = string
}))
})
default = {}
validation {
condition = var.seeding.type == null || contains(["none", "url", "text"], var.seeding.type)
error_message = "Invalid type"
}
}