Skip to content

Commit 1ec6f34

Browse files
akocbekakocbekIBM
andauthored
fix: do not create auth policy if existing_cos_instance_crn is null (#304)
Co-authored-by: [email protected] <[email protected]>
1 parent 565b633 commit 1ec6f34

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

solutions/standard/main.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ locals {
2222
parsed_existing_kms_instance_crn = var.existing_kms_instance_crn != null ? split(":", var.existing_kms_instance_crn) : []
2323
kms_region = length(local.parsed_existing_kms_instance_crn) > 0 ? local.parsed_existing_kms_instance_crn[5] : null
2424
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
25-
create_cross_account_auth_policy = (!var.skip_en_kms_auth_policy || !var.skip_cos_kms_auth_policy) && var.ibmcloud_kms_api_key != null
25+
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
2626
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.")
2727
en_key_name = var.prefix != null ? "${var.prefix}-${var.en_key_name}" : var.en_key_name
2828
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" {
121121
#######################################################################################################################
122122

123123
locals {
124-
# If a bucket namme is passed, or an existing EN CRN is passed; do not create bucket (or instance)
124+
# If a bucket name is passed, or an existing EN CRN is passed; do not create bucket (or instance)
125125
create_cos_bucket = var.existing_cos_bucket_name != null || var.existing_en_instance_crn != null ? false : true
126126
# tflint-ignore: terraform_unused_declarations
127127
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

tests/pr_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ func TestRunExistingResourcesInstances(t *testing.T) {
243243

244244
options.TerraformVars = []testschematic.TestSchematicTerraformVar{
245245
{Name: "ibmcloud_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
246+
{Name: "ibmcloud_kms_api_key", Value: options.RequiredEnvironmentVars["TF_VAR_ibmcloud_api_key"], DataType: "string", Secure: true},
246247
{Name: "region", Value: region, DataType: "string"},
247248
{Name: "resource_group_name", Value: terraform.Output(t, existingTerraformOptions, "resource_group_name"), DataType: "string"},
248249
{Name: "existing_kms_instance_crn", Value: permanentResources["hpcs_south_crn"], DataType: "string"},

0 commit comments

Comments
 (0)