Skip to content

Commit 6a2b6fa

Browse files
feat(deps): updated required terraform version to >=1.9.0 and updated variable validation logic (#319)
1 parent a39b7c9 commit 6a2b6fa

File tree

8 files changed

+31
-18
lines changed

8 files changed

+31
-18
lines changed

README.md

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

6868
| Name | Version |
6969
|------|---------|
70-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= v1.0.0 |
70+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= v1.9.0 |
7171
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.76.0, <2.0.0 |
7272
| <a name="requirement_time"></a> [time](#requirement\_time) | >= 0.9.1, < 1.0.0 |
7373

examples/basic/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 = ">= v1.0.0"
2+
required_version = ">= v1.9.0"
33

44
# Ensure that there is always 1 example locked into the lowest provider version of the range defined in the main
55
# module's version.tf (this example), and 1 example that will always use the latest provider version (complete example).

examples/complete/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ This examples handles the provisioning of a new Secrets Manager instance.
77

88
| Name | Version |
99
|------|---------|
10-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= v1.0.0 |
10+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= v1.9.0 |
1111
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >=1.76.0 |
1212
| <a name="requirement_time"></a> [time](#requirement\_time) | 0.12.1 |
1313

examples/complete/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 = ">= v1.0.0"
2+
required_version = ">= v1.9.0"
33
required_providers {
44
ibm = {
55
source = "IBM-Cloud/ibm"

examples/fscloud/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 latest version of provider in non-basic examples to verify latest version works with module
55
ibm = {

main.tf

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@
66
locals {
77
# Validation (approach based on https://github.com/hashicorp/terraform/issues/25609#issuecomment-1057614400)
88
# tflint-ignore: terraform_unused_declarations
9-
validate_kms_values = (!var.kms_encryption_enabled && var.kms_key_crn != null && var.existing_sm_instance_crn == null) ? tobool("When passing values for var.kms_key_crn, you must set 'kms_encryption_enabled' to true. Otherwise set 'kms_encryption_enabled' to false to use default encryption") : true
10-
# tflint-ignore: terraform_unused_declarations
11-
validate_kms_vars = var.kms_encryption_enabled && var.kms_key_crn == null && var.existing_sm_instance_crn == null ? tobool("When setting var.kms_encryption_enabled to true, a value must be passed for var.kms_key_crn") : true
12-
# tflint-ignore: terraform_unused_declarations
13-
validate_auth_policy = var.kms_encryption_enabled && var.skip_kms_iam_authorization_policy == false && var.kms_key_crn == null && var.existing_sm_instance_crn == null ? tobool("When var.skip_kms_iam_authorization_policy is set to false, and var.kms_encryption_enabled to true, a value must be passed for var.kms_key_crn in order to create the auth policy.") : true
14-
# tflint-ignore: terraform_unused_declarations
15-
validate_event_notification = var.enable_event_notification && var.existing_en_instance_crn == null ? tobool("When setting var.enable_event_notification to true, a value must be passed for var.existing_en_instance_crn") : true
16-
# tflint-ignore: terraform_unused_declarations
17-
validate_endpoint = var.endpoint_type == "public" && var.allowed_network == "private-only" && var.existing_sm_instance_crn == null ? tobool("It is not allowed to have conflicting var.endpoint_type and var.allowed_network values.") : true
18-
# tflint-ignore: terraform_unused_declarations
19-
validate_region = var.existing_sm_instance_crn == null && var.region == null ? tobool("When existing_sm_instance_crn is null, a value must be passed for var.region") : true
20-
# tflint-ignore: terraform_unused_declarations
219
validate_is_hpcs_key = var.is_hpcs_key && local.kms_service_name != "hs-crypto" ? tobool("When is_hpcs_key is set to true then the key provided through kms_key_crn must be a Hyper Protect Crypto Services key") : true
2210
}
2311

variables.tf

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ variable "kms_key_crn" {
6565
type = string
6666
description = "The root key CRN of a Key Management Service like Key Protect or Hyper Protect Crypto Services (HPCS) that you want to use for encryption. Only used if `kms_encryption_enabled` is set to true."
6767
default = null
68+
69+
validation {
70+
condition = var.kms_key_crn != null && var.kms_encryption_enabled == false ? false : true
71+
error_message = "When passing values for var.kms_key_crn, you must set 'kms_encryption_enabled' to true. Otherwise set 'kms_encryption_enabled' to false to use default encryption."
72+
}
73+
74+
validation {
75+
condition = var.kms_encryption_enabled == true && var.kms_key_crn == null ? false : true
76+
error_message = "When setting var.kms_encryption_enabled to true, a value must be passed for var.kms_key_crn."
77+
}
6878
}
6979

7080
variable "is_hpcs_key" {
@@ -77,6 +87,11 @@ variable "existing_sm_instance_crn" {
7787
type = string
7888
description = "An existing Secrets Manager instance CRN. If not provided an new instance will be provisioned."
7989
default = null
90+
91+
validation {
92+
condition = var.existing_sm_instance_crn == null && var.region == null ? false : true
93+
error_message = "When existing_sm_instance_crn is null, a value must be passed for var.region"
94+
}
8095
}
8196

8297
##############################################################
@@ -118,6 +133,11 @@ variable "enable_event_notification" {
118133
type = bool
119134
default = false
120135
description = "Set this to true to enable lifecycle notifications for your Secrets Manager instance by connecting an Event Notifications service. When setting this to true, a value must be passed for `existing_en_instance_crn` and `existing_sm_instance_crn` must be null."
136+
137+
validation {
138+
condition = var.enable_event_notification == true && var.existing_en_instance_crn == null ? false : true
139+
error_message = "When setting var.enable_event_notification to true, a value must be passed for var.existing_en_instance_crn"
140+
}
121141
}
122142

123143
variable "existing_en_instance_crn" {
@@ -134,6 +154,11 @@ variable "endpoint_type" {
134154
condition = contains(["public", "private"], var.endpoint_type)
135155
error_message = "The specified endpoint_type is not a valid selection!"
136156
}
157+
158+
validation {
159+
condition = var.endpoint_type == "public" && var.allowed_network == "private-only" ? false : true
160+
error_message = "It is not allowed to have conflicting `var.endpoint_type` and `var.allowed_network values`."
161+
}
137162
}
138163

139164
##############################################################

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 = ">= v1.0.0"
2+
required_version = ">= v1.9.0"
33
required_providers {
44
# Use "greater than or equal to" range in modules
55
ibm = {

0 commit comments

Comments
 (0)