Skip to content

Commit dbbbc72

Browse files
authored
fix: use nonsensitive for api_key comparison (required for DA to run on terraform 1.10) (#335)
1 parent 62e0d98 commit dbbbc72

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

solutions/instances/main.tf

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ module "cloud_monitoring_crn_parser" {
252252
module "observability_instance" {
253253
depends_on = [time_sleep.wait_for_atracker_cos_authorization_policy]
254254
source = "terraform-ibm-modules/observability-instances/ibm"
255-
version = "3.5.1"
255+
version = "3.5.2"
256256
region = var.region
257257
resource_group_id = module.resource_group.resource_group_id
258258

@@ -275,16 +275,26 @@ module "observability_instance" {
275275
cloud_logs_policies = var.cloud_logs_policies
276276
cloud_logs_data_storage = var.cloud_logs_provision ? {
277277
logs_data = {
278-
enabled = true
279-
bucket_crn = local.cloud_logs_data_bucket_crn
280-
bucket_endpoint = var.existing_cloud_logs_data_bucket_endpoint != null ? var.existing_cloud_logs_data_bucket_endpoint : module.cos_bucket[0].buckets[local.cloud_log_data_bucket].s3_endpoint_direct
281-
skip_cos_auth_policy = var.ibmcloud_cos_api_key != null ? true : var.skip_cloud_logs_cos_auth_policy
278+
enabled = true
279+
bucket_crn = local.cloud_logs_data_bucket_crn
280+
bucket_endpoint = var.existing_cloud_logs_data_bucket_endpoint != null ? var.existing_cloud_logs_data_bucket_endpoint : module.cos_bucket[0].buckets[local.cloud_log_data_bucket].s3_endpoint_direct
281+
# Even though we're only performing a comparison (var.ibmcloud_cos_api_key != null),
282+
# Terraform treats the entire value as "tainted" due to sensitivity.
283+
# Later, in the cloud_logs module, where the data_storage input variable is used in a for_each loop,
284+
# the loop fails with the error: "Sensitive values, or values derived from sensitive values, cannot be used as for_each arguments."
285+
# However, since we use nonsensitive() solely for logical comparison, we are not exposing any secret values to logs and it's safe to use. Issue https://github.ibm.com/GoldenEye/issues/issues/13562.
286+
skip_cos_auth_policy = nonsensitive(var.ibmcloud_cos_api_key) != null ? true : var.skip_cloud_logs_cos_auth_policy
282287
},
283288
metrics_data = {
284-
enabled = true
285-
bucket_crn = local.cloud_log_metrics_bucket_crn
286-
bucket_endpoint = var.existing_cloud_logs_metrics_bucket_endpoint != null ? var.existing_cloud_logs_metrics_bucket_endpoint : module.cos_bucket[0].buckets[local.cloud_log_metrics_bucket].s3_endpoint_direct
287-
skip_cos_auth_policy = var.ibmcloud_cos_api_key != null ? true : var.skip_cloud_logs_cos_auth_policy
289+
enabled = true
290+
bucket_crn = local.cloud_log_metrics_bucket_crn
291+
bucket_endpoint = var.existing_cloud_logs_metrics_bucket_endpoint != null ? var.existing_cloud_logs_metrics_bucket_endpoint : module.cos_bucket[0].buckets[local.cloud_log_metrics_bucket].s3_endpoint_direct
292+
# Even though we're only performing a comparison (var.ibmcloud_cos_api_key != null),
293+
# Terraform treats the entire value as "tainted" due to sensitivity.
294+
# Later, in the cloud_logs module, where the data_storage input variable is used in a for_each loop,
295+
# the loop fails with the error: "Sensitive values, or values derived from sensitive values, cannot be used as for_each arguments."
296+
# However, since we use nonsensitive() solely for logical comparison, we are not exposing any secret values to logs and it's safe to use. Issue https://github.ibm.com/GoldenEye/issues/issues/13562.
297+
skip_cos_auth_policy = nonsensitive(var.ibmcloud_cos_api_key) != null ? true : var.skip_cloud_logs_cos_auth_policy
288298
}
289299
} : null
290300
cloud_logs_existing_en_instances = [for index, _ in local.cloud_logs_existing_en_instances : {

0 commit comments

Comments
 (0)