From 665b7c95671313e58ae4cfe482f3d5f9429dc3cc Mon Sep 17 00:00:00 2001 From: huayuenh <48723418+huayuenh@users.noreply.github.com> Date: Tue, 23 Jul 2024 12:14:46 +0100 Subject: [PATCH] fix: add count to prefix module (#447) --- code-engine/main.tf | 6 +++++- main.tf | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/code-engine/main.tf b/code-engine/main.tf index 6e65bc59..ebc0afdf 100644 --- a/code-engine/main.tf +++ b/code-engine/main.tf @@ -61,6 +61,9 @@ locals { ci_repositories_prefix = (var.ci_repositories_prefix == "") ? var.repositories_prefix : var.ci_repositories_prefix cd_repositories_prefix = (var.cd_repositories_prefix == "") ? var.repositories_prefix : var.cd_repositories_prefix cc_repositories_prefix = (var.cc_repositories_prefix == "") ? var.repositories_prefix : var.cc_repositories_prefix + + enable_prereqs = ((var.create_icr_namespace == true) || (var.create_signing_certificate == true) || (var.create_secret_group == true) || + (var.create_ibmcloud_api_key == true) || (var.create_cos_api_key == true) || (var.create_signing_key == true)) ? true : false } data "ibm_resource_group" "resource_group" { @@ -77,6 +80,7 @@ resource "ibm_resource_instance" "cd_instance" { } module "prereqs" { + count = (local.enable_prereqs) ? 1 : 0 source = "../prereqs" depends_on = [data.ibm_resource_group.resource_group] create_icr_namespace = var.create_icr_namespace @@ -108,7 +112,7 @@ module "devsecops_ci_toolchain" { toolchain_region = (var.ci_toolchain_region == "") ? var.toolchain_region : replace(replace(var.ci_toolchain_region, "ibm:yp:", ""), "ibm:ys1:", "") toolchain_resource_group = (var.ci_toolchain_resource_group == "") ? var.toolchain_resource_group : var.ci_toolchain_resource_group toolchain_description = var.ci_toolchain_description - registry_namespace = module.prereqs.registry_namespace + registry_namespace = (local.enable_prereqs) ? module.prereqs[0].registry_namespace : var.registry_namespace ibmcloud_api = var.ibmcloud_api compliance_base_image = (var.ci_compliance_base_image == "") ? var.compliance_base_image : var.ci_compliance_base_image ci_pipeline_branch = (var.ci_compliance_pipeline_branch == "") ? var.compliance_pipeline_branch : var.ci_compliance_pipeline_branch diff --git a/main.tf b/main.tf index c84384d6..acceb70a 100644 --- a/main.tf +++ b/main.tf @@ -44,6 +44,9 @@ locals { ci_repositories_prefix = (var.ci_repositories_prefix == "") ? var.repositories_prefix : var.ci_repositories_prefix cd_repositories_prefix = (var.cd_repositories_prefix == "") ? var.repositories_prefix : var.cd_repositories_prefix cc_repositories_prefix = (var.cc_repositories_prefix == "") ? var.repositories_prefix : var.cc_repositories_prefix + + enable_prereqs = ((var.create_icr_namespace == true) || (var.create_signing_certificate == true) || (var.create_secret_group == true) || + (var.create_ibmcloud_api_key == true) || (var.create_cos_api_key == true) || (var.create_signing_key == true)) ? true : false } @@ -61,6 +64,7 @@ resource "ibm_resource_instance" "cd_instance" { } module "prereqs" { + count = (local.enable_prereqs) ? 1 : 0 source = "./prereqs" depends_on = [data.ibm_resource_group.resource_group] create_icr_namespace = var.create_icr_namespace @@ -92,7 +96,7 @@ module "devsecops_ci_toolchain" { toolchain_region = (var.ci_toolchain_region == "") ? var.toolchain_region : replace(replace(var.ci_toolchain_region, "ibm:yp:", ""), "ibm:ys1:", "") toolchain_resource_group = (var.ci_toolchain_resource_group == "") ? var.toolchain_resource_group : var.ci_toolchain_resource_group toolchain_description = var.ci_toolchain_description - registry_namespace = module.prereqs.registry_namespace + registry_namespace = (local.enable_prereqs) ? module.prereqs[0].registry_namespace : var.registry_namespace ibmcloud_api = var.ibmcloud_api compliance_base_image = (var.ci_compliance_base_image == "") ? var.compliance_base_image : var.ci_compliance_base_image ci_pipeline_branch = (var.ci_compliance_pipeline_branch == "") ? var.compliance_pipeline_branch : var.ci_compliance_pipeline_branch