|
3 | 3 | ############################################################################## |
4 | 4 |
|
5 | 5 | locals { |
6 | | - # variable validation around resource_group_id |
7 | | - rg_validate_condition = var.create_key_protect_instance && var.resource_group_id == null |
8 | | - rg_validate_msg = "A value must be passed for 'resource_group_id' when 'create_key_protect_instance' is true" |
9 | | - # tflint-ignore: terraform_unused_declarations |
10 | | - rg_validate_check = regex("^${local.rg_validate_msg}$", (!local.rg_validate_condition ? local.rg_validate_msg : "")) |
11 | 6 |
|
12 | 7 | parsed_existing_kms_instance_crn = var.existing_kms_instance_crn != null ? split(":", var.existing_kms_instance_crn) : [] |
13 | 8 | existing_kms_instance_guid = length(local.parsed_existing_kms_instance_crn) > 0 ? local.parsed_existing_kms_instance_crn[7] : null |
14 | 9 | existing_kms_account_id = length(local.parsed_existing_kms_instance_crn) > 0 ? split("/", local.parsed_existing_kms_instance_crn[6])[1] : null |
15 | 10 |
|
16 | | - # variable validation around new instance vs existing |
17 | | - instance_validate_condition = var.create_key_protect_instance && local.existing_kms_instance_guid != null |
18 | | - instance_validate_msg = "'create_key_protect_instance' cannot be true when passing a value for 'existing_key_protect_instance_guid'" |
19 | | - # tflint-ignore: terraform_unused_declarations |
20 | | - instance_validate_check = regex("^${local.instance_validate_msg}$", (!local.instance_validate_condition ? local.instance_validate_msg : "")) |
21 | | - |
22 | | - # variable validation when not creating new instance |
23 | | - existing_instance_validate_condition = !var.create_key_protect_instance && local.existing_kms_instance_guid == null |
24 | | - existing_instance_validate_msg = "A value must be provided for 'existing_key_protect_instance_guid' when 'create_key_protect_instance' is false" |
25 | | - # tflint-ignore: terraform_unused_declarations |
26 | | - existing_instance_validate_check = regex("^${local.existing_instance_validate_msg}$", (!local.existing_instance_validate_condition ? local.existing_instance_validate_msg : "")) |
27 | | - |
28 | 11 | # set key_protect_guid as either the ID of the passed in name of instance or the one created by this module |
29 | 12 | kms_guid = var.create_key_protect_instance ? module.key_protect[0].key_protect_guid : local.existing_kms_instance_guid |
30 | 13 |
|
|
0 commit comments