-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathvariables.tf
337 lines (291 loc) · 13.2 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# ----------------------------------------------------------------------------------------------------------------------
# REQUIRED PARAMETERS
# ----------------------------------------------------------------------------------------------------------------------
variable "name_suffix" {
description = "An arbitrary suffix that will be added to the end of the resource name(s). For example: an environment name, a business-case name, a numeric id, etc."
type = string
validation {
condition = length(var.name_suffix) <= 14
error_message = "A max of 14 character(s) are allowed."
}
}
variable "private_network" {
description = "A VPC network (self-link) that can access the MySQL instance via private IP. Can set to \"null\" if any of \"var.public_access_*\" is set to \"true\"."
type = string
}
# ----------------------------------------------------------------------------------------------------------------------
# OPTIONAL PARAMETERS
# ----------------------------------------------------------------------------------------------------------------------
variable "root_user_name" {
description = "The name of the root user."
type = string
default = "root"
}
variable "root_user_password" {
description = "The password of the root user. If not set (recommended to keep unset), a random password will be generated and will be available in the root_user_password output attribute."
type = string
default = ""
}
variable "root_user_host" {
description = "The host of the root user"
type = string
default = "%"
}
variable "full_name_master_instance" {
description = "Full name of the master instance. For backward-compatibility only. Not recommended for general use."
type = string
default = ""
}
variable "name_master_instance" {
description = "Portion of name to be generated for the \"Master\" instance. The same name of a deleted master instance cannot be reused for up to 7 days. See https://cloud.google.com/sql/docs/mysql/delete-instance > notes."
type = string
default = "v1"
}
variable "name_read_replica" {
description = "Portion of name to be generated for the \"ReadReplica\" instances. The same name of a deleted read-replica instance cannot be reused for up to 7 days. See https://cloud.google.com/sql/docs/mysql/delete-instance > notes."
type = string
default = "v1"
}
variable "db_version" {
description = "The MySQL database version to use. See https://cloud.google.com/sql/docs/mysql/db-versions."
type = string
default = "MYSQL_5_7"
}
variable "default_db_name" {
description = "Name of the default database to be created."
type = string
default = "default"
}
variable "default_db_charset" {
description = "The charset for the default database."
type = string
default = "utf8"
}
variable "default_db_collation" {
description = "The collation for the default database."
type = string
default = "utf8_general_ci"
}
variable "instance_size_master_instance" {
description = "The machine type/size of \"Master\" instance. See https://cloud.google.com/sql/pricing#2nd-gen-pricing."
type = string
default = "db-f1-micro"
}
variable "instance_size_read_replica" {
description = "The machine type/size of \"ReadReplica\" instances. See https://cloud.google.com/sql/pricing#2nd-gen-pricing."
type = string
default = "db-f1-micro"
}
variable "disk_size_gb_master_instance" {
description = "Disk size for the master instance in Giga Bytes."
type = number
default = 10
}
variable "disk_size_gb_read_replica" {
description = "Disk size for the read replica instance(s) in Giga Bytes."
type = number
default = 10
}
variable "disk_auto_resize_master_instance" {
description = "Whether to increase disk storage size of the master instance automatically. Increased storage size is permanent. Google charges by storage size whether that storage size is utilized or not. Recommended to set to \"true\" for production workloads."
type = bool
default = false
}
variable "disk_auto_resize_read_replica" {
description = "Whether to increase disk storage size of the read replica instance(s) automatically. Increased storage size is permanent. Google charges by storage size whether that storage size is utilized or not. Recommended to set to \"true\" for production workloads."
type = bool
default = false
}
variable "disk_autoresize_limit_read_replica" {
description = "Allows users to set a specific limit on how large the storage on their instance can automatically grow up to. The default value is zero, which means there is no limit and disk size can grow up to the maximum available storage for the instance tier. Applying the automatic disk increase limit does not cause any disruptions to your database workload."
type = number
default = 0
}
variable "backup_enabled" {
description = "Specify whether backups should be enabled for the MySQL instance."
type = bool
default = false
}
variable "backup_location" {
description = "A string value representing REGIONAL or MULTI-REGIONAL location for storing backups. Defaults to the Google provider's region if nothing is specified here. See https://cloud.google.com/sql/docs/mysql/locations for REGIONAL / MULTI-REGIONAL values."
type = string
default = ""
}
variable "pit_recovery_enabled" {
description = "Specify whether Point-In-Time recoevry should be enabled for the MySQL instance. It uses the \"binary log\" feature of CloudSQL. Value of 'true' requires 'var.backup_enabled' to be 'true'."
type = bool
default = false
}
variable "highly_available" {
description = "Whether the MySQL instance should be highly available (REGIONAL) or single zone. Highly Available (HA) instances will automatically failover to another zone within the region if there is an outage of the primary zone. HA instances are recommended for production use-cases and increase cost. Value of 'true' requires 'var.pit_recovery_enabled' to be 'true'."
type = bool
default = false
}
variable "highly_available_read_replica" {
description = "Whether the MySQL instance should be highly available (REGIONAL) or not (ZONAL). Highly Available (HA) instances will automatically failover to another zone within the region if there is an outage of the primary zone. HA instances are recommended for production use-cases and, therefore, increase cost"
type = bool
default = false
}
variable "read_replica_count" {
description = "Specify the number of read replicas for the MySQL instance. Value greater than 0 requires 'var.pit_recovery_enabled' to be 'true'."
type = number
default = 0
}
variable "allocated_ip_range_read_replica" {
description = <<-EOT
The name of the allocated IP range for the private IP of read replicas of the CloudSQL instance.
If already available this can be derived from VPC -> Private Service Connection -> Name of the allocated range. For example: "google-managed-services-default".
If set, the IP will be created within the allocated IP range.
The range name must comply with RFC 1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z?.
If set, a CIDR range of /20 is advised.
EOT
type = string
default = null
}
variable "authorized_networks_master_instance" {
description = "External networks that can access the MySQL master instance through HTTPS."
type = list(object({
display_name = string
cidr_block = string
}))
default = []
}
variable "authorized_networks_read_replica" {
description = "External networks that can access the MySQL ReadReplica instance(s) through HTTPS."
type = list(object({
display_name = string
cidr_block = string
}))
default = []
}
variable "region_master_instance" {
description = "The region to launch the master instance in. Defaults to the Google provider's region if nothing is specified here. See https://cloud.google.com/compute/docs/regions-zones"
type = string
default = ""
}
variable "region_read_replica" {
description = "The region to launch the ReadReplica instance(s) in. Defaults to the master instance's region if nothing is specified here. See https://cloud.google.com/compute/docs/regions-zones."
type = string
default = ""
}
variable "zone_master_instance" {
description = "The zone-letter to launch the master instance in. Options are \"a\" or \"b\" or \"c\" or \"d\". See https://cloud.google.com/compute/docs/regions-zones."
type = string
default = "a"
}
variable "zone_read_replica" {
description = "The zone-letter to launch the ReadReplica instance(s) in. Options are \"a\" or \"b\" or \"c\" or \"d\". See https://cloud.google.com/compute/docs/regions-zones."
type = string
default = "b"
}
variable "public_access_master_instance" {
description = "Whether public IPv4 address should be assigned to the MySQL master instance. If set to 'false' then 'var.private_network' must be defined."
type = bool
default = false
}
variable "allocated_ip_range" {
description = <<-EOT
The name of the allocated IP range for the private IP of the CloudSQL instance.
If already available this can be derived from VPC -> Private Service Connection -> Name of the allocated range. For example: "google-managed-services-default".
If set, the IP will be created within the allocated IP range.
The range name must comply with RFC 1035. Specifically, the name must be 1-63 characters long and match the regular expression a-z?.
If set, a CIDR range of /20 is advised.
EOT
type = string
default = null
}
variable "public_access_read_replica" {
description = "Whether public IPv4 address should be assigned to the MySQL read-replica instance(s). If set to 'false' then 'var.private_network' must be defined."
type = bool
default = false
}
variable "db_flags_master_instance" {
description = "The database flags applied to the master instance. See https://cloud.google.com/sql/docs/mysql/flags"
type = map(string)
default = {}
}
variable "db_flags_read_replica" {
description = "The database flags applied to the read replica instances. See https://cloud.google.com/sql/docs/mysql/flags"
type = map(string)
default = {}
}
variable "labels_master_instance" {
description = "Key/value labels for the master instance."
type = map(string)
default = {}
}
variable "labels_read_replica" {
description = "Key/value labels for the ReadReplica instance(s)."
type = map(string)
default = {}
}
variable "db_timeout" {
description = "How long a database operation is allowed to take before being considered a failure."
type = string
default = "30m"
}
variable "sql_proxy_user_groups" {
description = "List of usergroup emails that maybe allowed to connect with the database using CloudSQL Proxy. Connecting via CLoudSQL proxy from remote/localhost requires \"var.public_access_*\" to be set to \"true\" (for whichever of master/replica instances you want to connect to). See https://cloud.google.com/sql/docs/mysql/sql-proxy#what_the_proxy_provides"
type = list(string)
default = []
}
variable "deletion_protection_master_instance" {
description = "Used to prevent Terraform from deleting the master instance. Must apply with \"false\" first before attempting to delete in the next plan-apply."
type = bool
default = true
}
variable "deletion_protection_read_replica" {
description = "Used to prevent Terraform from deleting the ReadReplica. Must apply with \"false\" first before attempting to delete in the next plan-apply."
type = bool
default = true
}
variable "additional_users" {
description = "A list of additional users to be created in the CloudSQL instance"
type = list(object({
name = string
password = string
host = string
}))
default = []
}
variable "encryption_key_name_read_replica" {
description = "Encryption key is required for replicas in different regions. For replicas in same region as master, set encryption_key_name = null"
type = string
default = null
}
variable "additional_databases" {
description = "A list of additional databases to be created in the CloudSQL instance"
type = list(object({
name = string
charset = string
collation = string
}))
default = []
}
variable "maintenance_window" {
description = <<-EOT
day_utc: The day of the week (1-7) in UTC timezone - starting from Monday.
hour_utc: The hour of the day (0-23) in UTC timezone - ignored if day is not set.
update_track: The update track of maintenance window - can be either `canary` or `stable`.
default: Tuesday, 3:00 AM — 4:00 AM GMT+8
EOT
type = object({
day_utc = number
hour_utc = number
update_track = string
})
default = {
day_utc = 1
hour_utc = 19
update_track = "stable"
}
}
variable "insights_config" {
description = "The insights_config settings for the database."
type = object({
query_string_length = number
record_application_tags = bool
record_client_address = bool
})
default = null
}