You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
validate_kms_values=var.use_ibm_owned_encryption_key&& (var.kms_key_crn!=null|| var.backup_encryption_key_crn!=null) ?tobool("When passing values for 'kms_key_crn' or 'backup_encryption_key_crn', you must set 'use_ibm_owned_encryption_key' to false. Otherwise unset them to use default encryption.") :true
11
-
# tflint-ignore: terraform_unused_declarations
12
-
validate_kms_vars=!var.use_ibm_owned_encryption_key&& var.kms_key_crn==null?tobool("When setting 'use_ibm_owned_encryption_key' to false, a value must be passed for 'kms_key_crn'.") :true
13
-
# tflint-ignore: terraform_unused_declarations
14
-
validate_backup_key=!var.use_ibm_owned_encryption_key&& var.backup_encryption_key_crn!=null&& (var.use_default_backup_encryption_key|| var.use_same_kms_key_for_backups) ?tobool("When passing a value for 'backup_encryption_key_crn' you cannot set 'use_default_backup_encryption_key' to true or 'use_ibm_owned_encryption_key' to false.") :true
15
-
# tflint-ignore: terraform_unused_declarations
16
-
validate_backup_key_2=!var.use_ibm_owned_encryption_key&& var.backup_encryption_key_crn==null&&!var.use_same_kms_key_for_backups?tobool("When 'use_same_kms_key_for_backups' is set to false, a value needs to be passed for 'backup_encryption_key_crn'.") :true
17
-
# tflint-ignore: terraform_unused_declarations
18
-
validate_plan=var.enable_elser_model&& var.plan!="platinum"?tobool("When 'enable_elser_model' is set to true, the 'plan' must be set to 'platinum' in order to enable ELSER model.") :true
19
-
# tflint-ignore: terraform_unused_declarations
20
-
validate_es_user=var.enable_elser_model&&!((length(var.service_credential_names) >0&&length([fork, vinvar.service_credential_names:kifv=="Administrator"]) >0) || var.admin_pass!=null) ?tobool("When 'enable_elser_model' is set to true, an Administrator role user must be created using the 'service_credential_names' input, or by passing a value for the 'admin_pass' input.") :true
validate_kms_1=var.existing_elasticsearch_instance_crn!=null?true: var.use_ibm_owned_encryption_key&& (var.existing_kms_instance_crn!=null|| var.existing_kms_key_crn!=null|| var.existing_backup_kms_key_crn!=null) ?tobool("When setting values for 'existing_kms_instance_crn', 'existing_kms_key_crn' or 'existing_backup_kms_key_crn', the 'use_ibm_owned_encryption_key' input must be set to false.") :true
22
-
# tflint-ignore: terraform_unused_declarations
23
-
validate_kms_2=var.existing_elasticsearch_instance_crn!=null?true:!var.use_ibm_owned_encryption_key&& (var.existing_kms_instance_crn==null&& var.existing_kms_key_crn==null) ?tobool("When 'use_ibm_owned_encryption_key' is false, a value is required for either 'existing_kms_instance_crn' (to create a new key), or 'existing_kms_key_crn' to use an existing key.") :true
# Validate the region input matches region detected in existing instance CRN (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
259
-
# tflint-ignore: terraform_unused_declarations
260
-
validate_existing_instance_region=var.existing_elasticsearch_instance_crn!=null&& var.region!= local.existing_elasticsearch_region?tobool("The region detected in the 'existing_elasticsearch_instance_crn' value must match the value of the 'region' input variable when passing an existing instance.") :true
261
250
}
262
251
263
252
# Do a data lookup on the resource GUID to get more info that is needed for the 'ibm_database' data lookup below
## Variable validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
337
-
# tflint-ignore: terraform_unused_declarations
338
-
validate_sm_crn=length(local.service_credential_secrets) >0&& var.existing_secrets_manager_instance_crn==null?tobool("`existing_secrets_manager_instance_crn` is required when adding service credentials to a secrets manager secret.") :false
339
-
# tflint-ignore: terraform_unused_declarations
340
-
validate_sm_sg=var.existing_secrets_manager_instance_crn!=null&& var.admin_pass_secrets_manager_secret_group==null?tobool("`admin_pass_secrets_manager_secret_group` is required when `existing_secrets_manager_instance_crn` is set.") :false
341
-
# tflint-ignore: terraform_unused_declarations
342
-
validate_sm_sn=var.existing_secrets_manager_instance_crn!=null&& var.admin_pass_secrets_manager_secret_name==null?tobool("`admin_pass_secrets_manager_secret_name` is required when `existing_secrets_manager_instance_crn` is set.") :false
Copy file name to clipboardExpand all lines: solutions/standard/variables.tf
+61Lines changed: 61 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -56,12 +56,25 @@ variable "backup_crn" {
56
56
type=string
57
57
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."
58
58
default=null
59
+
60
+
validation {
61
+
condition=anytrue([
62
+
var.backup_crn==null,
63
+
can(regex("^crn:.*:backup:", var.backup_crn))
64
+
])
65
+
error_message="backup_crn must be null OR starts with 'crn:' and contains ':backup:'"
66
+
}
59
67
}
60
68
61
69
variable"region" {
62
70
type=string
63
71
description="The region where you want to deploy your instance, or the region in which your existing instance is in."
error_message="The region detected in the 'existing_elasticsearch_instance_crn' value must match the value of the 'region' input variable when passing an existing instance."
description="IBM Cloud Databases will secure your deployment's data at rest automatically with an encryption key that IBM hold. Alternatively, you may select your own Key Management System instance and encryption key (Key Protect or Hyper Protect Crypto Services) by setting this to false. If setting to false, a value must be passed for `existing_kms_instance_crn` to create a new key, or `existing_kms_key_crn` and/or `existing_backup_kms_key_crn` to use an existing key."
211
224
default=false
225
+
226
+
# this validation ensures IBM-owned key is not used when KMS details are provided
227
+
validation {
228
+
condition=(
229
+
var.existing_elasticsearch_instance_crn!=null||
230
+
!(var.use_ibm_owned_encryption_key&& (
231
+
var.existing_kms_instance_crn!=null||
232
+
var.existing_kms_key_crn!=null||
233
+
var.existing_backup_kms_key_crn!=null
234
+
))
235
+
)
236
+
error_message="When setting values for 'existing_kms_instance_crn', 'existing_kms_key_crn' or 'existing_backup_kms_key_crn', the 'use_ibm_owned_encryption_key' input must be set to false."
237
+
}
238
+
239
+
# this validation ensures key info is provided when IBM-owned key is disabled and no Elasticsearch instance is given
240
+
validation {
241
+
condition=!(
242
+
var.existing_elasticsearch_instance_crn==null&&
243
+
var.use_ibm_owned_encryption_key==false&&
244
+
var.existing_kms_instance_crn==null&&
245
+
var.existing_kms_key_crn==null
246
+
)
247
+
error_message="When 'use_ibm_owned_encryption_key' is false, you must provide either 'existing_kms_instance_crn' (to create a new key) or 'existing_kms_key_crn' (to use an existing key)."
description="The name of a new or existing secrets manager secret group for admin password. To use existing secret group, `use_existing_admin_pass_secrets_manager_secret_group` must be set to `true`. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
334
379
default="elasticsearch-secrets"
380
+
381
+
validation {
382
+
condition=(
383
+
var.existing_secrets_manager_instance_crn==null||
384
+
var.admin_pass_secrets_manager_secret_group!=null
385
+
)
386
+
error_message="`admin_pass_secrets_manager_secret_group` is required when `existing_secrets_manager_instance_crn` is set."
description="The name of a new elasticsearch administrator secret. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
346
399
default="elasticsearch-admin-password"
400
+
401
+
validation {
402
+
condition=(
403
+
var.existing_secrets_manager_instance_crn==null||
404
+
var.admin_pass_secrets_manager_secret_name!=null
405
+
)
406
+
error_message="`admin_pass_secrets_manager_secret_name` is required when `existing_secrets_manager_instance_crn` is set."
0 commit comments