forked from mineiros-io/terraform-google-cloud-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.tf
209 lines (173 loc) · 7.12 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
# ---------------------------------------------------------------------------------------------------------------------
# REQUIRED VARIABLES
# These variables must be set when using this module.
# ---------------------------------------------------------------------------------------------------------------------
variable "database_version" {
description = "(Required) The MySQL, PostgreSQL or SQL Server (beta) version to use."
type = string
validation {
condition = contains(["MYSQL_5_6", "MYSQL_5_7", "MYSQL_8_0", "POSTGRES_9_6", "POSTGRES_10", "POSTGRES_11", "POSTGRES_12", "POSTGRES_13"], var.database_version)
error_message = "The value must only be one of these valid values: MYSQL_5_6, MYSQL_5_7, MYSQL_8_0, POSTGRES_9_6, POSTGRES_10, POSTGRES_11, POSTGRES_12, POSTGRES_13."
}
}
variable "tier" {
description = "(Required) The machine type to use."
type = string
}
# ---------------------------------------------------------------------------------------------------------------------
# OPTIONAL VARIABLES
# These variables have defaults, but may be overridden.
# ---------------------------------------------------------------------------------------------------------------------
variable "name" {
description = "(Optional, Computed) The name of the instance. If the name is left blank, Terraform will randomly generate one when the instance is first created. This is done because after a name is used, it cannot be reused for up to one week."
type = string
default = null
}
variable "region" {
description = "(Optional) The region the instance will sit in. If a region is not provided in the resource definition, the provider region will be used instead."
type = string
default = null
}
variable "master_instance_name" {
description = "(Optional) The name of the existing instance that will act as the master in the replication setup. Note, this requires the master to have binary_log_enabled set, as well as existing backups."
type = string
default = null
}
variable "project" {
description = "(Optional) The ID of the project in which the resource belongs. If it is not provided, the provider project is used."
type = string
default = null
}
variable "deletion_protection" {
description = "(Optional) Whether or not to allow Terraform to destroy the instance."
type = bool
default = true
}
variable "activation_policy" {
description = "(Optional) This specifies when the instance should be active. Can be either ALWAYS, NEVER or ON_DEMAND."
type = string
default = null
validation {
condition = var.activation_policy == null || (var.activation_policy == null ? true : contains(["ALWAYS", "NEVER", "ON_DEMAND"], var.activation_policy))
error_message = "The value must only be one of these valid values: ALWAYS, NEVER, ON_DEMAND."
}
}
variable "availability_type" {
description = "(Optional) The availability type of the Cloud SQL instance, high availability (REGIONAL) or single zone (ZONAL).' For MySQL instances, ensure that settings.backup_configuration.enabled and settings.backup_configuration.binary_log_enabled are both set to true."
type = string
default = null
validation {
condition = var.availability_type == null || (var.availability_type == null ? true : contains(["REGIONAL", "ZONAL"], var.availability_type))
error_message = "The value must only be one of these valid values: REGIONAL, ZONAL."
}
}
variable "disk_autoresize" {
description = "(Optional) Configuration to increase storage size automatically. Default is `true` if no `var.disk_size` is set and `false` otherwise."
type = bool
default = true
}
variable "disk_size" {
description = "(Optional) The size of data disk, in GB. Size of a running instance cannot be reduced but can be increased. If `disk_size` is set `var.disk_autoresize` will be disbaled as terraform can not handle both."
type = number
default = null
}
variable "disk_type" {
description = "(Optional) The type of data disk: PD_SSD or PD_HDD."
type = string
default = "PD_SSD"
validation {
condition = contains(["PD_SSD", "PD_HDD"], var.disk_type)
error_message = "The value must only be one of these valid values: PD_SSD, PD_HDD."
}
}
variable "pricing_plan" {
description = "(Optional) Pricing plan for this instance, can only be PER_USE."
type = string
default = null
validation {
condition = var.pricing_plan == null || var.pricing_plan == "PER_USE"
error_message = "The value must only be PER_USE."
}
}
variable "user_labels" {
description = "(Optional) A set of key/value user label pairs to assign to the instance."
type = map(string)
default = {}
}
variable "database_flags" {
description = "(Optional) List of database flags."
type = any
default = []
}
variable "backup_configuration" {
description = "(Optional) List of backup configurations."
type = any
default = {}
}
variable "ip_configuration" {
description = "(Optional) List of ip configurations."
type = any
default = {}
}
variable "location_preference" {
description = "(Optional) A Map of location preferences."
type = any
default = {}
}
variable "maintenance_window" {
description = "(Optional) A Map of maintenance window."
type = any
default = {}
}
variable "insights_config" {
description = "(Optional) A Map of insight config."
type = any
default = {}
}
variable "replica_configuration" {
description = " (Optional) A Map of replica configuration."
type = any
default = {}
}
variable "module_timeouts" {
description = "(Optional) How long certain operations (per resource type) are allowed to take before being considered to have failed."
type = any
default = {}
}
variable "sql_databases" {
description = "(Optional) List of SQL Databases."
type = any
default = []
}
variable "sql_ssl_certs" {
description = "(Optional) List of SQL SSL Certs. You can create up to 10 client certificates for each instance."
type = any
default = []
validation {
condition = length(var.sql_ssl_certs) <= 10
error_message = "You can only create up to 10 client certificates for each instance."
}
}
variable "sql_users" {
description = "(Optional) List of SQL users."
type = any
default = []
validation {
condition = alltrue([for x in var.sql_users : can(x.name)])
error_message = "All SQL users must have a defined name."
}
}
# ------------------------------------------------------------------------------
# MODULE CONFIGURATION PARAMETERS
# These variables are used to configure the module.
# ------------------------------------------------------------------------------
variable "module_enabled" {
type = bool
description = "(Optional) Whether to create resources within the module or not. Default is 'true'."
default = true
}
variable "module_depends_on" {
type = any
description = "(Optional) A list of external resources the module depends_on. Default is '[]'."
default = []
}