|
1 | | -# Validation |
2 | | -# approach based on https://stackoverflow.com/a/66682419 |
3 | | -locals { |
4 | | - # public cert DNS config |
5 | | - dns_validate_condition = var.dns_config_name != null && var.internet_services_crn == null |
6 | | - dns_validate_msg = "A value for 'internet_services_crn' must be passed to create a DNS config for public_cert secrets engine" |
7 | | - # tflint-ignore: terraform_unused_declarations |
8 | | - dns_validate_check = regex("^${local.dns_validate_msg}$", (!local.dns_validate_condition ? local.dns_validate_msg : "")) |
9 | | - |
10 | | - # public cert CA config |
11 | | - ca_validate_condition = var.ca_config_name != null && (var.acme_letsencrypt_private_key == null && (var.private_key_secrets_manager_instance_guid == null || var.private_key_secrets_manager_secret_id == null)) |
12 | | - ca_validate_msg = "A value for 'acme_letsencrypt_private_key' must be passed to create a CA config for public_cert secrets engine" |
13 | | - # tflint-ignore: terraform_unused_declarations |
14 | | - ca_validate_check = regex("^${local.ca_validate_msg}$", (!local.ca_validate_condition ? local.ca_validate_msg : "")) |
15 | | - |
16 | | - # ensure an acme private key is being passed |
17 | | - # tflint-ignore: terraform_unused_declarations |
18 | | - validate_acme_values = (var.private_key_secrets_manager_instance_guid == null || var.private_key_secrets_manager_secret_id == null) && var.acme_letsencrypt_private_key == null ? tobool("A value for 'acme_letsencrypt_private_key' must be provided, or both `private_key_secrets_manager_instance_guid` and `private_key_secrets_manager_secret_id` must be provided to pull the private key.") : true |
19 | | - |
20 | | - create_access_policy_cis = !var.skip_iam_authorization_policy && var.dns_config_name != null && var.ibmcloud_cis_api_key == null |
21 | | -} |
22 | | - |
23 | 1 | # Data source to retrieve account ID |
24 | 2 | data "ibm_iam_account_settings" "iam_account_settings" { |
25 | 3 | } |
26 | 4 |
|
27 | 5 | locals { |
28 | | - cis_account_id = var.cis_account_id != null ? var.cis_account_id : data.ibm_iam_account_settings.iam_account_settings.account_id |
| 6 | + create_access_policy_cis = !var.skip_iam_authorization_policy && var.dns_config_name != null && var.ibmcloud_cis_api_key == null |
| 7 | + cis_account_id = var.cis_account_id != null ? var.cis_account_id : data.ibm_iam_account_settings.iam_account_settings.account_id |
29 | 8 | } |
30 | 9 |
|
31 | 10 | resource "ibm_iam_authorization_policy" "cis_service_authorization" { |
|
0 commit comments