diff --git a/modules/1_vpc_prepare/keys/create_new/keys.tf b/modules/1_vpc_prepare/keys/create_new/keys.tf index ab2525b..b757a71 100644 --- a/modules/1_vpc_prepare/keys/create_new/keys.tf +++ b/modules/1_vpc_prepare/keys/create_new/keys.tf @@ -23,12 +23,12 @@ locals { resource "ibm_is_ssh_key" "vpc_support_ssh_key_cond_create" { depends_on = [data.ibm_is_ssh_keys.keys] - count = length(data.ibm_is_ssh_keys.keys) == 0 ? 1 : 0 + count = !var.vpc_skip_ssh_key_create ? 1 : 0 name = "${var.vpc_name}-${var.name_prefix}-keypair" public_key = local.public_key resource_group = var.vpc_resource_group } locals { - key_id = local.keys == [] ? ibm_is_ssh_key.vpc_support_ssh_key_cond_create[0].id : local.keys[0].id + key_id = !var.vpc_skip_ssh_key_create ? ibm_is_ssh_key.vpc_support_ssh_key_cond_create[0].id : local.keys[0].id } \ No newline at end of file diff --git a/modules/1_vpc_prepare/keys/create_new/variables.tf b/modules/1_vpc_prepare/keys/create_new/variables.tf index bb0158a..162c365 100644 --- a/modules/1_vpc_prepare/keys/create_new/variables.tf +++ b/modules/1_vpc_prepare/keys/create_new/variables.tf @@ -7,4 +7,5 @@ variable "public_key_file" {} variable "public_key" {} variable "vpc_name" {} variable "vpc_resource_group" {} -variable "name_prefix" {} \ No newline at end of file +variable "name_prefix" {} +variable "vpc_skip_ssh_key_create" {} \ No newline at end of file diff --git a/modules/1_vpc_prepare/keys/keys.tf b/modules/1_vpc_prepare/keys/keys.tf index e36d821..887f2c5 100644 --- a/modules/1_vpc_prepare/keys/keys.tf +++ b/modules/1_vpc_prepare/keys/keys.tf @@ -32,4 +32,5 @@ module "create_new" { vpc_name = var.vpc_name vpc_resource_group = var.vpc_resource_group name_prefix = var.name_prefix + vpc_skip_ssh_key_create =var.vpc_skip_ssh_key_create } \ No newline at end of file diff --git a/modules/1_vpc_prepare/keys/outputs.tf b/modules/1_vpc_prepare/keys/outputs.tf index eea4b65..84c1e61 100644 --- a/modules/1_vpc_prepare/keys/outputs.tf +++ b/modules/1_vpc_prepare/keys/outputs.tf @@ -4,9 +4,9 @@ ################################################################ output "vpc_check_key" { - value = var.vpc_create || var.create_custom_subnet ? module.create_new.vpc_check_key : module.check.check_key + value = var.vpc_create || var.create_custom_subnet || !var.vpc_skip_ssh_key_create ? module.create_new.vpc_check_key : module.check.check_key } output "vpc_key_id" { - value = var.vpc_create || var.create_custom_subnet ? module.create_new.vpc_key_id : module.check.keys + value = var.vpc_create || var.create_custom_subnet || !var.vpc_skip_ssh_key_create ? module.create_new.vpc_key_id : module.check.keys }