-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.tf
More file actions
494 lines (421 loc) · 14.2 KB
/
variables.tf
File metadata and controls
494 lines (421 loc) · 14.2 KB
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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
################################################################################
# General
################################################################################
variable "create" {
description = "Whether to create DDS resources"
type = bool
default = true
}
variable "region" {
description = "The Huawei Cloud region where resources will be created. If not specified, the region configured in the provider will be used"
type = string
default = null
}
variable "tags" {
description = "A mapping of tags to assign to all resources"
type = map(string)
default = {}
}
variable "dds_instance_tags" {
description = "Additional tags for the DDS instance"
type = map(string)
default = {}
}
################################################################################
# DDS Instance
################################################################################
variable "create_dds_instance" {
description = "Whether to create a DDS instance"
type = bool
default = true
}
variable "identifier" {
description = "The name of the DDS instance. Must be 4 to 64 characters and start with a letter"
type = string
}
variable "use_identifier_prefix" {
description = "Determines whether to use `identifier` as is or create a unique identifier beginning with `identifier` as the specified prefix"
type = bool
default = false
}
variable "mode" {
description = "Specifies the mode of the database instance. Valid values: Sharding, ReplicaSet"
type = string
validation {
condition = contains(["Sharding", "ReplicaSet"], var.mode)
error_message = "Mode must be either 'Sharding' or 'ReplicaSet'."
}
}
variable "availability_zone" {
description = "Specifies the availability zone names separated by commas"
type = string
}
variable "vpc_id" {
description = "The VPC ID where the DDS instance will be created"
type = string
}
variable "subnet_id" {
description = "The subnet ID where the DDS instance will be created"
type = string
}
variable "security_group_id" {
description = "The security group ID to associate with the DDS instance"
type = string
}
################################################################################
# Datastore Configuration
################################################################################
variable "datastore_type" {
description = "Specifies the DB engine. Currently only 'DDS-Community' is supported"
type = string
default = "DDS-Community"
}
variable "datastore_version" {
description = "Specifies the DB instance version. Valid values: 4.0, 4.2, 4.4, 5.0"
type = string
}
variable "datastore_storage_engine" {
description = <<-EOF
Specifies the storage engine of the DB instance.
- For version 4.0: wiredTiger
- For versions 4.2, 4.4, 5.0: rocksDB
If not specified, defaults based on version
EOF
type = string
default = null
}
################################################################################
# Authentication & Access
################################################################################
variable "password" {
description = "Specifies the Administrator password of the database instance. Must be 8-32 characters long and contain at least three types: uppercase letters, lowercase letters, digits, and special characters"
type = string
sensitive = true
}
variable "port" {
description = "Specifies the database access port. Valid values: 2100-9500, 27017, 27018, 27019. Defaults to 8635"
type = number
default = null
}
variable "disk_encryption_id" {
description = "Specifies the disk encryption ID of the instance"
type = string
default = null
}
################################################################################
# Flavor Configuration
################################################################################
variable "flavors" {
description = <<-EOF
List of flavor configurations for the DDS instance.
For Sharding mode:
- mongos: type = "mongos", num = 2-16, spec_code required, storage/size not applicable
- shard: type = "shard", num = 2-16, spec_code required, storage/size required
- config: type = "config", num = 1, spec_code required, storage/size required
For ReplicaSet mode:
- replica: type = "replica", num = 3/5/7, spec_code required, storage/size required
Example for Sharding:
[
{
type = "mongos"
num = 2
spec_code = "dds.mongodb.c3.medium.4.mongos"
},
{
type = "shard"
num = 2
storage = "ULTRAHIGH"
size = 20
spec_code = "dds.mongodb.c3.medium.4.shard"
},
{
type = "config"
num = 1
storage = "ULTRAHIGH"
size = 20
spec_code = "dds.mongodb.c3.large.2.config"
}
]
Example for ReplicaSet:
[
{
type = "replica"
num = 3
storage = "ULTRAHIGH"
size = 30
spec_code = "dds.mongodb.c3.medium.4.repset"
}
]
EOF
type = list(object({
type = string
num = number
spec_code = string
storage = optional(string)
size = optional(number)
}))
}
################################################################################
# Configuration Template
################################################################################
variable "configuration_id" {
description = "Specifies the ID of the parameter template to use"
type = string
default = null
}
variable "configuration_type" {
description = "Specifies the node type for configuration. Valid values: mongos, shard, config (for Sharding), replica (for ReplicaSet)"
type = string
default = null
}
################################################################################
# Backup Strategy
################################################################################
variable "backup_strategy" {
description = <<-EOF
Backup strategy configuration for automated backups.
Example:
{
start_time = "08:00-09:00"
keep_days = 8
period = "1,3,5" # Optional, backup cycle (days of week: 1=Monday, 7=Sunday)
}
EOF
type = object({
start_time = string
keep_days = number
period = optional(string)
})
default = null
}
################################################################################
# Maintenance Window
################################################################################
variable "maintenance_window" {
description = "The maintenance window for the DDS instance. Format: 'HH:MM-HH:MM' in UTC+0. Example: '02:00-03:00'"
type = string
default = null
}
################################################################################
# ReplicaSet Specific Settings
################################################################################
variable "replica_set_name" {
description = "Specifies the name of the replica set in the connection address. Must be 3-128 characters, start with a letter. Default is 'replica'"
type = string
default = null
}
variable "client_network_ranges" {
description = "Specifies the CIDR block where the client is located. Cross-CIDR access is required only when the CIDR blocks of the client and the replica set instance are different. Only for ReplicaSet mode"
type = list(string)
default = []
}
################################################################################
# Advanced Settings
################################################################################
variable "ssl" {
description = "Specifies whether to enable or disable SSL. Defaults to true. NOTE: The instance will be restarted when switching SSL"
type = bool
default = null
}
variable "second_level_monitoring_enabled" {
description = "Specifies whether to enable second level monitoring"
type = bool
default = null
}
variable "slow_log_desensitization" {
description = "Specifies whether to enable slow original log. Valid values: 'on', 'off'"
type = string
default = null
}
variable "balancer_status" {
description = "Specifies the status of the balancer. Valid values: 'start', 'stop'. Defaults to 'start'. Only for Sharding mode"
type = string
default = null
}
variable "balancer_active_begin" {
description = "Specifies the start time of the balancing activity time window. Format: HH:MM in UTC. Required with balancer_active_end. Only for Sharding mode"
type = string
default = null
}
variable "balancer_active_end" {
description = "Specifies the end time of the balancing activity time window. Format: HH:MM in UTC. Required with balancer_active_begin. Only for Sharding mode"
type = string
default = null
}
variable "enterprise_project_id" {
description = "The enterprise project ID for the DDS instance"
type = string
default = null
}
variable "description" {
description = "Description of the DDS instance"
type = string
default = null
}
################################################################################
# Billing Configuration
################################################################################
variable "charging_mode" {
description = "Specifies the charging mode of the DDS instance. Valid values: 'prePaid' (yearly/monthly), 'postPaid' (pay-per-use, default)"
type = string
default = "postPaid"
validation {
condition = contains(["prePaid", "postPaid"], var.charging_mode)
error_message = "charging_mode must be either 'prePaid' or 'postPaid'."
}
}
variable "period_unit" {
description = "Specifies the charging period unit. Required when charging_mode is 'prePaid'. Valid values: 'month', 'year'"
type = string
default = null
}
variable "period" {
description = "Specifies the charging period. Required when charging_mode is 'prePaid'. Valid: 1-9 (month), 1-3 (year)"
type = number
default = null
}
variable "auto_renew" {
description = "Specifies whether to automatically renew prepaid instance. Valid values: 'true', 'false'"
type = string
default = null
}
################################################################################
# Database Users & Roles
################################################################################
variable "create_database_users" {
description = "Whether to create database users for the DDS instance"
type = bool
default = false
}
variable "database_users" {
description = <<-EOF
List of database users to create for the DDS instance.
Example:
[
{
name = "appuser"
password = "SecurePassword123!"
db_name = "mydb"
roles = [
{
name = "readWrite"
db_name = "mydb"
}
]
}
]
EOF
type = list(object({
name = string
password = string
db_name = string
roles = optional(list(object({
name = string
db_name = string
})), [])
}))
default = []
}
variable "create_database_roles" {
description = "Whether to create database roles for the DDS instance"
type = bool
default = false
}
variable "database_roles" {
description = <<-EOF
List of database roles to create for the DDS instance.
Example:
[
{
name = "readonly_role"
db_name = "mydb"
roles = [
{
name = "read"
db_name = "mydb"
}
]
}
]
EOF
type = list(object({
name = string
db_name = string
roles = optional(list(object({
name = string
db_name = string
})), [])
}))
default = []
}
################################################################################
# LTS Logging
################################################################################
variable "create_lts_logs" {
description = "Whether to create LTS log configurations for the DDS instance"
type = bool
default = false
}
variable "lts_logs" {
description = <<-EOF
List of LTS log configurations for the DDS instance.
Example:
[
{
log_type = "audit_log"
lts_group_id = "group-id-xxxxx"
lts_stream_id = "stream-id-xxxxx"
}
]
EOF
type = list(object({
log_type = string
lts_group_id = string
lts_stream_id = string
}))
default = []
}
################################################################################
# Audit Log Policy
################################################################################
variable "create_audit_log_policy" {
description = "Whether to create an audit log policy for the DDS instance"
type = bool
default = false
}
variable "audit_log_keep_days" {
description = "Specifies the number of days for storing audit logs. The value ranges from 7 to 732"
type = number
default = 7
}
variable "audit_log_scope" {
description = <<-EOF
Specifies the audit scope. If this parameter is left blank or set to 'all', all audit log policies are enabled.
You can enter the database or collection name. Use commas (,) to separate multiple databases or collections.
Maximum 1024 characters.
EOF
type = string
default = null
}
variable "audit_log_types" {
description = "Specifies the audit type. Valid values: auth, insert, delete, update, query, command"
type = list(string)
default = null
}
variable "audit_log_reserve_auditlogs" {
description = <<-EOF
Specifies whether the historical audit logs are retained when SQL audit is disabled.
true (default): indicates that historical audit logs are retained when SQL audit is disabled.
false: indicates that existing historical audit logs are deleted when SQL audit is disabled.
EOF
type = string
default = null
}
################################################################################
# Timeouts
################################################################################
variable "timeouts" {
description = "Terraform resource management timeouts"
type = map(string)
default = {}
}