generated from terraform-ibm-modules/terraform-ibm-module-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
variables.tf
272 lines (235 loc) · 12.5 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
##############################################################################
# Input Variables
##############################################################################
variable "resource_group_id" {
type = string
description = "The resource group ID where the Redis instance will be created."
}
variable "instance_name" {
type = string
description = "The name to give the Redis instance."
}
variable "redis_version" {
type = string
description = "Version of the Redis instance to provision. If no value is passed, the current preferred version of IBM Cloud Databases is used."
default = null
validation {
condition = anytrue([
var.redis_version == null,
var.redis_version == "6.2",
var.redis_version == "7.2"
])
error_message = "Version must be 6.2 or 7.2. If no value passed, the current ICD preferred version is used."
}
}
variable "region" {
type = string
description = "The region where you want to deploy your instance."
default = "us-south"
}
##############################################################################
# ICD hosting model properties
##############################################################################
variable "members" {
type = number
description = "Allocated number of members. Members can be scaled up but not down."
default = 2
# Validation is done in terraform plan phase by IBM provider, so no need to add any extra validation here
}
variable "cpu_count" {
type = number
description = "Allocated dedicated CPU per member. For shared CPU, set to 0. [Learn more](https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling)"
default = 0
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
}
variable "disk_mb" {
type = number
description = "Allocated disk per member. [Learn more](https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling)"
default = 1024
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
}
variable "member_host_flavor" {
type = string
description = "Allocated host flavor per member. [Learn more](https://registry.terraform.io/providers/IBM-Cloud/ibm/latest/docs/resources/database#host_flavor)."
default = null
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
}
variable "memory_mb" {
type = number
description = "Allocated memory per member. [Learn more](https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-resources-scaling)"
default = 4096
# Validation is done in the Terraform plan phase by the IBM provider, so no need to add extra validation here.
}
variable "admin_pass" {
type = string
description = "The password for the database administrator. If the admin password is null then the admin user ID cannot be accessed. More users can be specified in a user block."
default = null
sensitive = true
}
variable "users" {
type = list(object({
name = string
password = string # pragma: allowlist secret
type = optional(string)
role = optional(string)
}))
description = "A list of users that you want to create on the database. Users block is supported by Redis version >= 6.0. Multiple blocks are allowed. The user password must be in the range of 10-32 characters. Be warned that in most case using IAM service credentials (via the var.service_credential_names) is sufficient to control access to the Redis instance. This blocks creates native redis database users, more info on that can be found here https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-user-management&interface=ui"
default = []
sensitive = true
}
variable "service_credential_names" {
type = map(string)
description = "Map of name, role for service credentials that you want to create for the database"
default = {}
validation {
condition = alltrue([for name, role in var.service_credential_names : contains(["Administrator", "Operator", "Viewer", "Editor"], role)])
error_message = "Valid values for service credential roles are 'Administrator', 'Operator', 'Viewer', and `Editor`"
}
}
variable "endpoints" {
type = string
description = "Specify whether you want to enable the public, private, or both service endpoints. Supported values are 'public', 'private', or 'public-and-private'."
default = "private"
validation {
condition = can(regex("public|public-and-private|private", var.endpoints))
error_message = "Valid values for service_endpoints are 'public', 'public-and-private', and 'private'"
}
}
variable "tags" {
type = list(any)
description = "Optional list of tags to be added to the Redis instance."
default = []
}
variable "access_tags" {
type = list(string)
description = "A list of access tags to apply to the Redis instance created by the module, see https://cloud.ibm.com/docs/account?topic=account-access-tags-tutorial for more details"
default = []
validation {
condition = alltrue([
for tag in var.access_tags : can(regex("[\\w\\-_\\.]+:[\\w\\-_\\.]+", tag)) && length(tag) <= 128
])
error_message = "Tags must match the regular expression \"[\\w\\-_\\.]+:[\\w\\-_\\.]+\", see https://cloud.ibm.com/docs/account?topic=account-tag&interface=ui#limits for more details"
}
}
variable "configuration" {
type = object({
maxmemory = optional(number)
maxmemory-policy = optional(string)
appendonly = optional(string)
maxmemory-samples = optional(number)
stop-writes-on-bgsave-error = optional(string)
})
description = "Database Configuration. Default values will get picked up if not all the values are passed."
default = null
}
##############################################################
# Auto Scaling
##############################################################
variable "auto_scaling" {
type = object({
disk = object({
capacity_enabled = optional(bool, false)
free_space_less_than_percent = optional(number, 10)
io_above_percent = optional(number, 90)
io_enabled = optional(bool, false)
io_over_period = optional(string, "15m")
rate_increase_percent = optional(number, 10)
rate_limit_mb_per_member = optional(number, 3670016)
rate_period_seconds = optional(number, 900)
rate_units = optional(string, "mb")
})
memory = object({
io_above_percent = optional(number, 90)
io_enabled = optional(bool, false)
io_over_period = optional(string, "15m")
rate_increase_percent = optional(number, 10)
rate_limit_mb_per_member = optional(number, 114688)
rate_period_seconds = optional(number, 900)
rate_units = optional(string, "mb")
})
})
description = "Optional rules to allow the database to increase resources in response to usage. Only a single autoscaling block is allowed. Make sure you understand the effects of autoscaling, especially for production environments. See https://cloud.ibm.com/docs/databases-for-redis?topic=databases-for-redis-autoscaling in the IBM Cloud Docs."
default = null
}
##############################################################
# Encryption
##############################################################
variable "kms_encryption_enabled" {
type = bool
description = "Set this to true to control the encryption keys used to encrypt the data that you store in IBM Cloud® Databases. If set to false, the data is encrypted by using randomly generated keys. For more info on Key Protect integration, see https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect. For more info on HPCS integration, see https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs"
default = false
}
variable "use_default_backup_encryption_key" {
type = bool
description = "Set to true to use default ICD randomly generated keys."
default = false
}
variable "kms_key_crn" {
type = string
description = "The root key CRN of a Key Management Services like Key Protect or Hyper Protect Crypto Services (HPCS) that you want to use for disk encryption. Only used if var.kms_encryption_enabled is set to true."
default = null
validation {
condition = anytrue([
var.kms_key_crn == null,
can(regex(".*kms.*", var.kms_key_crn)),
can(regex(".*hs-crypto.*", var.kms_key_crn)),
])
error_message = "Value must be the root key CRN from either the Key Protect or Hyper Protect Crypto Services (HPCS)"
}
}
variable "backup_encryption_key_crn" {
type = string
description = "The CRN of a KMS (Key Protect or Hyper Protect Crypto Services) key to use for encrypting the disk that holds deployment backups. Only used if var.kms_encryption_enabled is set to true. There are limitation per region on the type of KMS service (Key Protect or Hyper Protect Crypto Services) and region for those services. See https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-key-protect&interface=ui#key-byok and https://cloud.ibm.com/docs/cloud-databases?topic=cloud-databases-hpcs#use-hpcs-backups"
default = null
validation {
condition = var.backup_encryption_key_crn == null ? true : length(regexall("^crn:v1:bluemix:public:kms:(us-south|us-east|eu-de):a/[[:xdigit:]]{32}:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}:key:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$|^crn:v1:bluemix:public:hs-crypto:[a-z-]+:a/[[:xdigit:]]{32}:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}:key:[[:xdigit:]]{8}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{4}-[[:xdigit:]]{12}$", var.backup_encryption_key_crn)) > 0
error_message = "Valid values for backup_encryption_key_crn is null, a Hyper Protect Crypto Services key CRN or a Key Protect key CRN from us-south, us-east or eu-de"
}
}
variable "skip_iam_authorization_policy" {
type = bool
description = "Set to true to skip the creation of an IAM authorization policy that permits all Redis database instances in the resource group to read the encryption key from the KMS instance. If set to false, pass in a value for the KMS instance in the existing_kms_instance_guid variable. In addition, no policy is created if var.kms_encryption_enabled is set to false."
default = false
}
variable "existing_kms_instance_guid" {
type = string
description = "The GUID of the Hyper Protect Crypto Services or Key Protect instance in which the key specified in var.kms_key_crn and var.backup_encryption_key_crn is coming from. Required only if var.kms_encryption_enabled is set to true, var.skip_iam_authorization_policy is set to false, and you pass a value for var.kms_key_crn, var.backup_encryption_key_crn, or both."
default = null
}
##############################################################
# Context-based restriction (CBR)
##############################################################
variable "cbr_rules" {
type = list(object({
description = string
account_id = string
rule_contexts = list(object({
attributes = optional(list(object({
name = string
value = string
}))) }))
enforcement_mode = string
tags = optional(list(object({
name = string
value = string
})))
}))
description = "(Optional, list) List of CBR rules to create"
default = []
# Validation happens in the rule module
}
##############################################################
# Backup
##############################################################
variable "backup_crn" {
type = string
description = "The CRN of a backup resource to restore from. The backup is created by a database deployment with the same service ID. The backup is loaded after provisioning and the new deployment starts up that uses that data. A backup CRN is in the format crn:v1:<…>:backup:. If omitted, the database is provisioned empty."
default = null
validation {
condition = anytrue([
var.backup_crn == null,
can(regex("^crn:.*:backup:", var.backup_crn))
])
error_message = "backup_crn must be null OR starts with 'crn:' and contains ':backup:'"
}
}