Skip to content

Commit 1450f85

Browse files
fix: removed outdated validation<br>* update required terraform version to 1.9 (#503)
1 parent 4f3c010 commit 1450f85

File tree

8 files changed

+40
-20
lines changed

8 files changed

+40
-20
lines changed

README.md

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

9595
| Name | Version |
9696
|------|---------|
97-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
97+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9.0 |
9898
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.15.0, <3.0.0 |
9999
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.70.0, <2.0.0 |
100100

examples/obs-agent-iks/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

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 (obs-agent-ocp).

examples/obs-agent-ocp/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

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 (obs-agent-iks), and 1 example that will always use the latest provider version (this exammple).

main.tf

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,6 @@ locals {
3535
cloud_monitoring_agent_registry = "icr.io/ext/sysdig/agent"
3636
cloud_monitoring_agent_tags = var.cloud_monitoring_add_cluster_name ? concat(["ibm.containers-kubernetes.cluster.name:${local.cluster_name}"], var.cloud_monitoring_agent_tags) : var.cloud_monitoring_agent_tags
3737
cloud_monitoring_host = var.cloud_monitoring_enabled ? var.cloud_monitoring_endpoint_type == "private" ? "ingest.private.${var.cloud_monitoring_instance_region}.monitoring.cloud.ibm.com" : "logs.${var.cloud_monitoring_instance_region}.monitoring.cloud.ibm.com" : null
38-
39-
# TODO: Move this into variable.tf since module requires 1.9 now
40-
# VARIABLE VALIDATION
41-
cloud_monitoring_key_validate_condition = var.cloud_monitoring_enabled == true && var.cloud_monitoring_instance_region == null && var.cloud_monitoring_access_key == null
42-
cloud_monitoring_key_validate_msg = "Values for 'cloud_monitoring_access_key' and 'log_analysis_instance_region' variables must be passed when 'cloud_monitoring_enabled = true'"
43-
# tflint-ignore: terraform_unused_declarations
44-
cloud_monitoring_key_validate_check = regex("^${local.cloud_monitoring_key_validate_msg}$", (!local.cloud_monitoring_key_validate_condition ? local.cloud_monitoring_key_validate_msg : ""))
45-
# Logs Agent Validation
46-
# tflint-ignore: terraform_unused_declarations
47-
validate_iam_mode = var.logs_agent_enabled == true && (var.logs_agent_iam_mode == "IAMAPIKey" && (var.logs_agent_iam_api_key == null || var.logs_agent_iam_api_key == "")) ? tobool("When passing 'IAMAPIKey' value for 'logs_agent_iam_mode' you cannot set 'logs_agent_iam_api_key' as null or empty string.") : true
48-
# tflint-ignore: terraform_unused_declarations
49-
validate_trusted_profile_mode = var.logs_agent_enabled == true && (var.logs_agent_iam_mode == "TrustedProfile" && (var.logs_agent_trusted_profile == null || var.logs_agent_trusted_profile == "")) ? tobool(" When passing 'TrustedProfile' value for 'logs_agent_iam_mode' you cannot set 'logs_agent_trusted_profile' as null or empty string.") : true
50-
# tflint-ignore: terraform_unused_declarations
51-
validate_icl_ingress_endpoint = var.logs_agent_enabled == true && (var.cloud_logs_ingress_endpoint == null || var.cloud_logs_ingress_endpoint == "") ? tobool("When 'logs_agent_enabled' is enabled, you cannot set 'cloud_logs_ingress_endpoint' as null or empty string.") : true
5238
}
5339

5440
/** Cloud Monitoring Configuration Start **/

modules/logs-agent/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ module "logs_agent_module" {
5959

6060
| Name | Version |
6161
|------|---------|
62-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.3.0 |
62+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.9.0 |
6363
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.11.0, <3.0.0 |
6464
| <a name="requirement_ibm"></a> [ibm](#requirement\_ibm) | >= 1.59.0, <2.0.0 |
6565

modules/logs-agent/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

44
# Each required provider's version should be a flexible range to future proof the module's usage with upcoming minor and patch versions.
55
required_providers {

variables.tf

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ variable "cloud_monitoring_enabled" {
5959
type = bool
6060
description = "Deploy IBM Cloud Monitoring agent"
6161
default = true
62+
63+
validation {
64+
condition = !var.cloud_monitoring_enabled || (
65+
var.cloud_monitoring_access_key != null &&
66+
var.cloud_monitoring_instance_region != null
67+
)
68+
error_message = "When cloud_monitoring_enabled is true, both cloud_monitoring_access_key and cloud_monitoring_instance_region must be provided."
69+
}
6270
}
6371

6472
variable "cloud_monitoring_access_key" {
@@ -196,13 +204,31 @@ variable "logs_agent_trusted_profile" {
196204
type = string
197205
description = "The IBM Cloud trusted profile ID. Used only when `logs_agent_iam_mode` is set to `TrustedProfile`. The trusted profile must have an IBM Cloud Logs `Sender` role."
198206
default = null
207+
208+
validation {
209+
condition = (
210+
var.logs_agent_enabled == false ||
211+
var.logs_agent_iam_mode != "TrustedProfile" ||
212+
(var.logs_agent_trusted_profile != null && var.logs_agent_trusted_profile != "")
213+
)
214+
error_message = "When passing 'TrustedProfile' value for 'logs_agent_iam_mode' you cannot set 'logs_agent_trusted_profile' as null or empty string."
215+
}
199216
}
200217

201218
variable "logs_agent_iam_api_key" {
202219
type = string
203220
description = "The IBM Cloud API key for the Logs agent to authenticate and communicate with the IBM Cloud Logs. It is required if `logs_agent_iam_mode` is set to `IAMAPIKey`."
204221
sensitive = true
205222
default = null
223+
224+
validation {
225+
condition = (
226+
var.logs_agent_enabled == false ||
227+
var.logs_agent_iam_mode != "IAMAPIKey" ||
228+
(var.logs_agent_iam_api_key != null && var.logs_agent_iam_api_key != "")
229+
)
230+
error_message = "When passing 'IAMAPIKey' value for 'logs_agent_iam_mode', you cannot set 'logs_agent_iam_api_key' as null or empty string."
231+
}
206232
}
207233

208234
variable "logs_agent_tolerations" {
@@ -278,6 +304,14 @@ variable "cloud_logs_ingress_endpoint" {
278304
description = "The host for IBM Cloud Logs ingestion. Ensure you use the ingress endpoint. See https://cloud.ibm.com/docs/cloud-logs?topic=cloud-logs-endpoints_ingress."
279305
type = string
280306
default = null
307+
308+
validation {
309+
condition = (
310+
var.logs_agent_enabled == false ||
311+
(var.cloud_logs_ingress_endpoint != null && var.cloud_logs_ingress_endpoint != "")
312+
)
313+
error_message = "When 'logs_agent_enabled' is enabled, you cannot set 'cloud_logs_ingress_endpoint' as null or empty string."
314+
}
281315
}
282316

283317
variable "cloud_logs_ingress_port" {

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

44
# Each required provider's version should be a flexible range to future proof the module's usage with upcoming minor and patch versions.
55
required_providers {

0 commit comments

Comments
 (0)