terraform-ibm-modules / terraform-ibm-observability-da

A deployable architecture solution to deploy Observability instances and agents.
Apache License 2.0
0 stars 1 forks source link

Validation error when using existing instances #156

Closed in-1911 closed 2 weeks ago

in-1911 commented 1 month ago

Similar to #132 - actually testing the same use case.

When the module is used with enable_at_event_routing_to_cos_bucket = false and log_analysis_provision = false, the module should ignore all COS-related inputs (including KMS attributes / inputs).

This scenario is likely to occur in a DA stack context where observability components has already been deployed elsewhere and the stack just needs to skip provisioning new observability resources.

Affected modules

solutions/instances/main.tf

Terraform CLI and Terraform provider versions

Terraform output

Inputs:

existing_cos_kms_key_crn = null
enable_at_event_routing_to_cos_bucket = false
enable_at_event_routing_to_log_analysis = false
log_analysis_provision = false
enable_platform_logs = false
cloud_monitoring_provision = false

log_analysis_enable_archive = false 

existing_log_archive_cos_bucket_name = null
existing_log_archive_cos_bucket_endpoint = null
existing_at_cos_target_bucket_name = null
existing_at_cos_target_bucket_endpoint = null

existing_cos_instance_crn = null
existing_kms_instance_crn = <valid KMS CRN>
existing_cloud_monitoring_crn = <valid Monitoring instance CRN>

Plan result:

2024/09/11 23:51:23 Terraform plan | Error: Invalid index
 2024/09/11 23:51:23 Terraform plan | 
 2024/09/11 23:51:23 Terraform plan |   on main.tf line 25, in locals:
 2024/09/11 23:51:23 Terraform plan |   25:   cos_kms_key_crn             = (var.existing_log_archive_cos_bucket_name != null && var.existing_at_cos_target_bucket_name != null) ? null : var.existing_cos_kms_key_crn != null ? var.existing_cos_kms_key_crn : module.kms[0].keys[format("%!s(MISSING).%!s(MISSING)", local.cos_key_ring_name, local.cos_key_name)].crn
 2024/09/11 23:51:23 Terraform plan |     ├────────────────
 2024/09/11 23:51:23 Terraform plan |     │ module.kms is empty tuple
 2024/09/11 23:51:23 Terraform plan | 
 2024/09/11 23:51:23 Terraform plan | The given key does not identify an element in this collection value: the
 2024/09/11 23:51:23 Terraform plan | collection has no elements.

Affected modules

*

Terraform CLI and Terraform provider versions

Terraform output

Debug output

Expected behavior

The module should not provision any resources and return the Cloud Monitoring CRN as output.

Actual behavior

Steps to reproduce (including links and screen captures)

  1. Run terraform apply

Anything else


By submitting this issue, you agree to follow our Code of Conduct

iamar7 commented 2 weeks ago

Resolved in https://github.com/terraform-ibm-modules/terraform-ibm-observability-da/pull/137