Skip to content

next_step_primary_url breaks terraform when passing value for existing_kms_instance_crn in DA #807

@ocofaigh

Description

@ocofaigh

Looks like there is an issue with the code that was added in #790

2025/12/03 17:00:01 Terraform plan | Error: Invalid function argument
 2025/12/03 17:00:01 Terraform plan | 
 2025/12/03 17:00:01 Terraform plan |   on outputs.tf line 82, in output "next_step_primary_url":
 2025/12/03 17:00:01 Terraform plan |   82:   value       = "[https://cloud.ibm.com/keyprotect/${urlencode(module.kms.key_protect_crn)}?paneId=manage](https://cloud.ibm.com/keyprotect/$%7Burlencode(module.kms.key_protect_crn)%7D?paneId=manage)"
 2025/12/03 17:00:01 Terraform plan |     ├────────────────
 2025/12/03 17:00:01 Terraform plan |     │ while calling urlencode(str)
 2025/12/03 17:00:01 Terraform plan |     │ module.kms.key_protect_crn is null
 2025/12/03 17:00:01 Terraform plan | 
 2025/12/03 17:00:01 Terraform plan | Invalid value for "str" parameter: argument must not be null.

This error was seen when passing a value for existing_kms_instance_crn into the DA. The above output needs to consider that module.kms.key_protect_crn might be null in this case, and hence needs to be updated to use a local variable thats determined like below:

locals {
  kms_crn = var.existing_kms_instance_crn == null ? module.kms.key_protect_crn : var.existing_kms_instance_crn
}

The output named kms_instance_crn already uses above logic, so if we are creating a new local, suggest to update the output to also use the new local.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions