forked from walrus-catalog/terraform-alicloud-rds-postgresql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
variables.tf
191 lines (174 loc) · 5.98 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
186
187
188
189
190
191
#
# 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:
vpc_id: string # the ID of the VPC where the PostgreSQL service applies
kms_key_id: string,optional # the ID of the KMS key which to encrypt the PostgreSQL data
domain_suffix: string,optional # a private DNS namespace of the PrivateZone where to register the applied PostgreSQL service
publicly_accessible: bool # whether the PostgreSQL service is publicly accessible
```
EOF
type = object({
vpc_id = string
kms_key_id = optional(string)
domain_suffix = optional(string)
publicly_accessible = optional(bool, false)
})
}
#
# 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://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createdbinstance.
EOF
type = string
default = "16.0"
validation {
condition = var.engine_version == "" || contains(["16.0", "15.0", "14.0", "13.0"], var.engine_version)
error_message = "Invalid version"
}
}
variable "engine_parameters" {
description = <<-EOF
Specify the deployment engine parameters, select for https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-describeparametertemplates.
EOF
type = list(object({
name = string
value = string
}))
default = []
}
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.
See https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createdatabase.
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(expect `pg` prefix), combined with number, or symbol: _.
The username cannot be PostgreSQL forbidden keyword and postgres.
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 == "" || (var.username != "postgres" && can(regex("^[^pg][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 generate a random password.
See https://www.alibabacloud.com/help/en/rds/developer-reference/api-rds-2014-08-15-createaccount.
EOF
type = string
sensitive = true
default = null
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.
The computing resource design of Alibaba Cloud is very complex, it also needs to consider on the storage resource, please view the specification document for more information.
Examples:
```
resources:
class: string, optional # https://www.alibabacloud.com/help/en/rds/apsaradb-rds-for-postgresql/primary-apsaradb-rds-for-postgresql-instance-types
readonly_class: string, optional # https://www.alibabacloud.com/help/en/rds/apsaradb-rds-for-postgresql/read-only-apsaradb-rds-for-postgresql-instance-types
```
EOF
type = object({
class = optional(string, "pg.n2.2c.1m")
readonly_class = optional(string)
})
default = {
class = "pg.n2.2c.1m"
}
}
variable "storage" {
description = <<-EOF
Specify the storage resources, select from local_ssd, cloud_ssd, cloud_essd, cloud_essd2 or cloud_essd3.
Choosing the storage resource is also related to the computing resource, please view the specification document for more information.
Examples:
```
storage:
class: string, optional # https://registry.terraform.io/providers/aliyun/alicloud/latest/docs/resources/db_instance#db_instance_storage_type
size: number, optional # in megabyte
```
EOF
type = object({
class = optional(string, "cloud_essd")
size = optional(number, 20 * 1024)
})
default = {
class = "cloud_essd"
size = 20 * 1024
}
validation {
condition = var.storage == null || try(var.storage.size >= 20480, true)
error_message = "Storage size must be larger than 20480Mi"
}
}