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
# Validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
10
-
# tflint-ignore: terraform_unused_declarations
11
-
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
12
-
# tflint-ignore: terraform_unused_declarations
13
-
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
14
-
# tflint-ignore: terraform_unused_declarations
15
-
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
16
-
# tflint-ignore: terraform_unused_declarations
17
-
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
validate_kms_1=var.existing_rabbitmq_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_rabbitmq_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)
258
-
# tflint-ignore: terraform_unused_declarations
259
-
validate_existing_instance_region=var.existing_rabbitmq_instance_crn!=null&& var.region!= local.existing_rabbitmq_region?tobool("The region detected in the 'existing_rabbitmq_instance_crn' value must match the value of the 'region' input variable when passing an existing instance.") :true
260
249
}
261
250
262
251
# Do a data lookup on the resource GUID to get more info that is needed for the 'ibm_database' data lookup below
@@ -328,13 +317,6 @@ locals {
328
317
329
318
locals {
330
319
## Variable validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
331
-
# tflint-ignore: terraform_unused_declarations
332
-
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
333
-
# tflint-ignore: terraform_unused_declarations
334
-
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
335
-
# tflint-ignore: terraform_unused_declarations
336
-
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
error_message="The region detected in the 'existing_rabbitmq_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."
129
134
default=false
135
+
136
+
# this validation ensures IBM-owned key is not used when KMS details are provided
137
+
validation {
138
+
condition=(
139
+
var.existing_rabbitmq_instance_crn!=null||
140
+
!(var.use_ibm_owned_encryption_key&& (
141
+
var.existing_kms_instance_crn!=null||
142
+
var.existing_kms_key_crn!=null||
143
+
var.existing_backup_kms_key_crn!=null
144
+
))
145
+
)
146
+
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."
147
+
}
148
+
149
+
# this validation ensures key info is provided when IBM-owned key is disabled and no RabbitMQ instance is given
150
+
validation {
151
+
condition=!(
152
+
var.existing_rabbitmq_instance_crn==null&&
153
+
var.use_ibm_owned_encryption_key==false&&
154
+
var.existing_kms_instance_crn==null&&
155
+
var.existing_kms_key_crn==null
156
+
)
157
+
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."
307
344
default="rabbitmq-secrets"
345
+
346
+
validation {
347
+
condition=(
348
+
var.existing_secrets_manager_instance_crn==null||
349
+
var.admin_pass_secrets_manager_secret_group!=null
350
+
)
351
+
error_message="`admin_pass_secrets_manager_secret_group` is required when `existing_secrets_manager_instance_crn` is set."
description="The name of a new rabbitmq administrator secret. If a prefix input variable is specified, the prefix is added to the name in the `<prefix>-<name>` format."
319
364
default="rabbitmq-admin-password"
365
+
366
+
validation {
367
+
condition=(
368
+
var.existing_secrets_manager_instance_crn==null||
369
+
var.admin_pass_secrets_manager_secret_name!=null
370
+
)
371
+
error_message="`admin_pass_secrets_manager_secret_name` is required when `existing_secrets_manager_instance_crn` is set."
0 commit comments