diff --git a/solutions/standard/main.tf b/solutions/standard/main.tf index bd41fafd..29d90dd9 100644 --- a/solutions/standard/main.tf +++ b/solutions/standard/main.tf @@ -22,7 +22,7 @@ locals { parsed_existing_kms_instance_crn = var.existing_kms_instance_crn != null ? split(":", var.existing_kms_instance_crn) : [] kms_region = length(local.parsed_existing_kms_instance_crn) > 0 ? local.parsed_existing_kms_instance_crn[5] : null kms_instance_guid = var.existing_kms_instance_crn != null ? element(split(":", var.existing_kms_instance_crn), length(split(":", var.existing_kms_instance_crn)) - 3) : module.kms[0].kms_instance_guid - create_cross_account_auth_policy = (!var.skip_en_kms_auth_policy || !var.skip_cos_kms_auth_policy) && var.ibmcloud_kms_api_key != null + create_cross_account_auth_policy = (!var.skip_en_kms_auth_policy || !var.skip_cos_kms_auth_policy) && var.ibmcloud_kms_api_key != null && var.existing_cos_instance_crn != null existing_kms_guid = var.existing_kms_instance_crn != null ? element(split(":", var.existing_kms_instance_crn), length(split(":", var.existing_kms_instance_crn)) - 3) : tobool("The CRN of the existing KMS is not provided.") en_key_name = var.prefix != null ? "${var.prefix}-${var.en_key_name}" : var.en_key_name en_key_ring_name = var.prefix != null ? "${var.prefix}-${var.en_key_ring_name}" : var.en_key_ring_name @@ -121,7 +121,7 @@ module "kms" { ####################################################################################################################### locals { - # If a bucket namme is passed, or an existing EN CRN is passed; do not create bucket (or instance) + # If a bucket name is passed, or an existing EN CRN is passed; do not create bucket (or instance) create_cos_bucket = var.existing_cos_bucket_name != null || var.existing_en_instance_crn != null ? false : true # tflint-ignore: terraform_unused_declarations validate_cos_regions = var.cos_bucket_region != null && var.cross_region_location != null ? tobool("Cannot provide values for var.cos_bucket_region and var.cross_region_location") : true diff --git a/tests/pr_test.go b/tests/pr_test.go index e56edeb9..1767bc89 100644 --- a/tests/pr_test.go +++ b/tests/pr_test.go @@ -243,6 +243,7 @@ func TestRunExistingResourcesInstances(t *testing.T) { options.TerraformVars = []testschematic.TestSchematicTerraformVar{ {Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, + {Name: "ibmcloud_kms_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true}, {Name: "region", Value: region, DataType: "string"}, {Name: "resource_group_name", Value: terraform.Output(t, existingTerraformOptions, "resource_group_name"), DataType: "string"}, {Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},