Skip to content

Commit e1e72c7

Browse files
authored
fix(deps): updated required terraform version to >=1.9.0 and updated the variable validation logic (#225)
1 parent 3218c05 commit e1e72c7

File tree

6 files changed

+16
-27
lines changed

6 files changed

+16
-27
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ You need the following permissions to run this module.
162162

163163
| Name | Version |
164164
|------|---------|
165-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
165+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9.0 |
166166
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.76.0, < 2.0.0 |
167167
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, < 1.0.0 |
168168

examples/api_key_auth/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.3.0"
2+
required_version = ">= 1.9.0"
33
required_providers {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {

examples/iam_auth/version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.3.0"
2+
required_version = ">= 1.9.0"
33
required_providers {
44
# Pin to the lowest provider version of the range defined in the main module to ensure lowest version still works
55
ibm = {

main.tf

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
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-
231
# Data source to retrieve account ID
242
data "ibm_iam_account_settings" "iam_account_settings" {
253
}
264

275
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
298
}
309

3110
resource "ibm_iam_authorization_policy" "cis_service_authorization" {

variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ variable "internet_services_crn" {
2424
type = string
2525
description = "CRN of the CIS instance to authorize Secrets Manager against"
2626
default = null
27+
28+
validation {
29+
condition = var.dns_config_name != null ? var.internet_services_crn != null : true
30+
error_message = "A value for 'internet_services_crn' must be passed to create a DNS config for public_cert secrets engine"
31+
}
2732
}
2833

2934
variable "cis_account_id" {
@@ -61,6 +66,11 @@ variable "acme_letsencrypt_private_key" {
6166
description = "The private key generated by the ACME account creation tool. Required if private_key_secrets_manager_instance_guid and private_key_secrets_manager_secret_id are not set."
6267
default = null
6368
sensitive = true
69+
70+
validation {
71+
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) : true : true
72+
error_message = "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 to create a CA config for public_cert secrets engine."
73+
}
6474
}
6575

6676
variable "service_endpoints" {

version.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
terraform {
2-
required_version = ">= 1.3.0"
2+
required_version = ">= 1.9.0"
33
required_providers {
44
# Use "greater than or equal to" range in modules
55
ibm = {

0 commit comments

Comments
 (0)