forked from terraform-google-modules/terraform-google-sql-db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
469 lines (409 loc) · 15.1 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
variable "project_id" {
description = "The project ID to manage the Cloud SQL resources"
type = string
}
// required
variable "region" {
description = "The region of the Cloud SQL resources"
type = string
default = "us-central1"
}
variable "name" {
type = string
description = "The name of the Cloud SQL resources"
}
variable "edition" {
description = "The edition of the instance, can be ENTERPRISE or ENTERPRISE_PLUS."
type = string
default = null
}
// required
variable "database_version" {
description = "The database version to use"
type = string
}
variable "maintenance_version" {
description = "The current software version on the instance. This attribute can not be set during creation. Refer to available_maintenance_versions attribute to see what maintenance_version are available for upgrade. When this attribute gets updated, it will cause an instance restart. Setting a maintenance_version value that is older than the current one on the instance will be ignored"
type = string
default = null
}
variable "availability_type" {
description = "The availability type for the master instance. Can be either `REGIONAL` or `null`."
type = string
default = "REGIONAL"
}
variable "enable_default_db" {
description = "Enable or disable the creation of the default database"
type = bool
default = true
}
variable "db_name" {
description = "The name of the default database to create. This should be unique per Cloud SQL instance."
type = string
default = "default"
}
variable "enable_default_user" {
description = "Enable or disable the creation of the default user"
type = bool
default = true
}
variable "user_name" {
description = "The name of the default user"
type = string
default = "default"
}
variable "user_password" {
description = "The password for the default user. If not set, a random one will be generated and available in the generated_user_password output variable."
type = string
default = ""
}
variable "user_host" {
description = "The host for the default user"
type = string
default = "%"
}
variable "root_password" {
description = "MySQL password for the root user."
type = string
default = null
}
variable "deletion_protection" {
description = "Used to block Terraform from deleting a SQL Instance."
type = bool
default = true
}
variable "user_deletion_policy" {
description = "The deletion policy for the user. Setting ABANDON allows the resource to be abandoned rather than deleted. This is useful for Postgres, where users cannot be deleted from the API if they have been granted SQL roles. Possible values are: \"ABANDON\"."
type = string
default = null
}
variable "data_cache_enabled" {
description = "Whether data cache is enabled for the instance. Defaults to false. Feature is only available for ENTERPRISE_PLUS tier and supported database_versions"
type = bool
default = false
}
variable "additional_databases" {
description = "A list of databases to be created in your cluster"
type = list(object({
name = string
charset = string
collation = string
}))
default = []
}
variable "additional_users" {
description = "A list of users to be created in your cluster. A random password would be set for the user if the `random_password` variable is set."
type = list(object({
name = string
password = string
random_password = bool
type = string
host = string
}))
default = []
validation {
condition = length([for user in var.additional_users : false if user.random_password == true && (user.password != null && user.password != "")]) == 0
error_message = "You cannot set both password and random_password, choose one of them."
}
}
variable "iam_users" {
description = "A list of IAM users to be created in your CloudSQL instance. iam.users.type can be CLOUD_IAM_USER, CLOUD_IAM_SERVICE_ACCOUNT, CLOUD_IAM_GROUP and is required for type CLOUD_IAM_GROUP (IAM groups)"
type = list(object({
id = string,
email = string,
type = optional(string)
}))
default = []
}
variable "random_instance_name" {
type = bool
description = "Sets random suffix at the end of the Cloud SQL resource name"
default = false
}
variable "replica_database_version" {
description = "The read replica database version to use. This var should only be used during a database update. The update sequence 1. read-replica 2. master, setting this to an updated version will cause the replica to update, then you may update the master with the var database_version and remove this field after update is complete"
type = string
default = ""
}
// optional
variable "master_instance_name" {
description = "The name of the existing instance that will act as the master in the replication setup."
type = string
default = null
}
// optional
variable "instance_type" {
description = "Users can upgrade a read replica instance to a stand-alone Cloud SQL instance with the help of instance_type. To promote, users have to set the instance_type property as CLOUD_SQL_INSTANCE and remove/unset master_instance_name and replica_configuration from instance configuration. This operation might cause your instance to restart."
type = string
default = null
}
// Master
variable "tier" {
description = "The tier for the master instance."
type = string
default = "db-n1-standard-1"
}
variable "zone" {
description = "The zone for the master instance, it should be something like: `us-central1-a`, `us-east1-c`."
type = string
default = null
}
variable "secondary_zone" {
type = string
description = "The preferred zone for the secondary/failover instance, it should be something like: `us-central1-a`, `us-east1-c`."
default = null
}
variable "follow_gae_application" {
type = string
description = "A Google App Engine application whose zone to remain in. Must be in the same region as this instance."
default = null
}
variable "activation_policy" {
description = "The activation policy for the master instance. Can be either `ALWAYS`, `NEVER` or `ON_DEMAND`."
type = string
default = "ALWAYS"
}
variable "deletion_protection_enabled" {
description = "Enables protection of an instance from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform)."
type = bool
default = false
}
variable "read_replica_deletion_protection_enabled" {
description = "Enables protection of a read replica from accidental deletion across all surfaces (API, gcloud, Cloud Console and Terraform)."
type = bool
default = false
}
variable "disk_autoresize" {
description = "Configuration to increase storage size"
type = bool
default = true
}
variable "disk_autoresize_limit" {
description = "The maximum size to which storage can be auto increased."
type = number
default = 0
}
variable "disk_size" {
description = "The disk size (in GB) for the master instance"
type = number
default = 10
}
variable "disk_type" {
description = "The disk type for the master instance."
type = string
default = "PD_SSD"
}
variable "pricing_plan" {
description = "The pricing plan for the master instance."
type = string
default = "PER_USE"
}
variable "maintenance_window_day" {
description = "The day of week (1-7) for the master instance maintenance."
type = number
default = 1
}
variable "maintenance_window_hour" {
description = "The hour of day (0-23) maintenance window for the master instance maintenance."
type = number
default = 23
}
variable "maintenance_window_update_track" {
description = "The update track of maintenance window for the master instance maintenance. Can be either `canary` or `stable`."
type = string
default = "canary"
}
variable "database_flags" {
description = "List of Cloud SQL flags that are applied to the database server. See [more details](https://cloud.google.com/sql/docs/mysql/flags)"
type = list(object({
name = string
value = string
}))
default = []
}
variable "user_labels" {
type = map(string)
default = {}
description = "The key/value labels for the master instances."
}
variable "deny_maintenance_period" {
description = "The Deny Maintenance Period fields to prevent automatic maintenance from occurring during a 90-day time period. List accepts only one value. See [more details](https://cloud.google.com/sql/docs/mysql/maintenance)"
type = list(object({
end_date = string
start_date = string
time = string
}))
default = []
}
variable "backup_configuration" {
description = "The backup_configuration settings subblock for the database setings"
type = object({
binary_log_enabled = optional(bool, false)
enabled = optional(bool, false)
start_time = optional(string)
location = optional(string)
transaction_log_retention_days = optional(string)
retained_backups = optional(number)
retention_unit = optional(string)
})
default = {}
}
variable "insights_config" {
description = "The insights_config settings for the database."
type = object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
})
default = null
}
variable "ip_configuration" {
description = "The ip_configuration settings subblock"
type = object({
authorized_networks = optional(list(map(string)), [])
ipv4_enabled = optional(bool, true)
private_network = optional(string)
ssl_mode = optional(string)
allocated_ip_range = optional(string)
enable_private_path_for_google_cloud_services = optional(bool, false)
psc_enabled = optional(bool, false)
psc_allowed_consumer_projects = optional(list(string), [])
})
default = {}
}
variable "password_validation_policy_config" {
description = "The password validation policy settings for the database instance."
type = object({
enable_password_policy = bool
min_length = optional(number)
complexity = optional(string)
disallow_username_substring = optional(bool)
reuse_interval = optional(number)
})
default = null
}
// Read Replicas
variable "read_replicas" {
description = "List of read replicas to create. Encryption key is required for replica in different region. For replica in same region as master set encryption_key_name = null"
type = list(object({
name = string
name_override = optional(string)
tier = optional(string)
edition = optional(string)
availability_type = optional(string)
zone = optional(string)
disk_type = optional(string)
disk_autoresize = optional(bool)
disk_autoresize_limit = optional(number)
disk_size = optional(string)
user_labels = map(string)
database_flags = list(object({
name = string
value = string
}))
backup_configuration = optional(object({
binary_log_enabled = bool
transaction_log_retention_days = string
}))
insights_config = optional(object({
query_plans_per_minute = number
query_string_length = number
record_application_tags = bool
record_client_address = bool
}))
ip_configuration = object({
authorized_networks = optional(list(map(string)), [])
ipv4_enabled = optional(bool)
private_network = optional(string, )
ssl_mode = optional(string)
allocated_ip_range = optional(string)
enable_private_path_for_google_cloud_services = optional(bool, false)
psc_enabled = optional(bool, false)
psc_allowed_consumer_projects = optional(list(string), [])
})
encryption_key_name = optional(string)
data_cache_enabled = optional(bool)
}))
default = []
}
variable "read_replica_name_suffix" {
description = "The optional suffix to add to the read instance name"
type = string
default = ""
}
variable "db_charset" {
description = "The charset for the default database"
type = string
default = ""
}
variable "db_collation" {
description = "The collation for the default database. Example: 'utf8_general_ci'"
type = string
default = ""
}
variable "create_timeout" {
description = "The optional timout that is applied to limit long database creates."
type = string
default = "30m"
}
variable "update_timeout" {
description = "The optional timout that is applied to limit long database updates."
type = string
default = "30m"
}
variable "delete_timeout" {
description = "The optional timout that is applied to limit long database deletes."
type = string
default = "30m"
}
variable "encryption_key_name" {
description = "The full path to the encryption key used for the CMEK disk encryption"
type = string
default = null
}
variable "module_depends_on" {
description = "List of modules or resources this module depends on."
type = list(any)
default = []
}
variable "read_replica_deletion_protection" {
description = "Used to block Terraform from deleting replica SQL Instances."
type = bool
default = false
}
variable "enable_random_password_special" {
description = "Enable special characters in generated random passwords."
type = bool
default = false
}
variable "connector_enforcement" {
description = "Enforce that clients use the connector library"
type = bool
default = false
}
variable "enable_google_ml_integration" {
description = "Enable database ML integration"
type = bool
default = false
}
variable "database_integration_roles" {
description = "The roles required by default database instance service account for integration with GCP services"
type = list(string)
default = []
}