@@ -79,7 +79,7 @@ module "network-vcn-config" {
7979
8080module "network-lb-nsg" {
8181 source = " ./modules/network/nsg"
82- count = local. use_existing_lb ? 0 : local. add_load_balancer && local. lb_subnet_1_subnet_cidr != " " ? 1 : 0
82+ count = local. use_existing_lb ? 0 : local. add_load_balancer && ! local . use_existing_subnets && local. lb_subnet_1_subnet_cidr != " " ? 1 : 0
8383 compartment_id = local. network_compartment_id
8484 vcn_id = local. vcn_id
8585 nsg_name = " ${ local . service_name_prefix } -lb-nsg"
@@ -92,7 +92,7 @@ module "network-lb-nsg" {
9292
9393module "network-bastion-nsg" {
9494 source = " ./modules/network/nsg"
95- count = var. is_bastion_instance_required && var. existing_bastion_instance_id == " " && local. bastion_subnet_cidr != " " ? 1 : 0
95+ count = var. is_bastion_instance_required && var. existing_bastion_instance_id == " " && ! local . use_existing_subnets && local. bastion_subnet_cidr != " " ? 1 : 0
9696 compartment_id = local. network_compartment_id
9797 vcn_id = local. vcn_id
9898 nsg_name = " ${ local . service_name_prefix } -bastion-nsg"
@@ -105,7 +105,7 @@ module "network-bastion-nsg" {
105105
106106module "network-mount-target-nsg" {
107107 source = " ./modules/network/nsg"
108- count = var. add_fss && local. mount_target_subnet_cidr != " " ? 1 : 0
108+ count = var. add_fss && ! local . use_existing_subnets && local. mount_target_subnet_cidr != " " ? 1 : 0
109109 compartment_id = local. network_compartment_id
110110 vcn_id = local. vcn_id
111111 nsg_name = " ${ local . service_name_prefix } -mount-target-nsg"
@@ -118,7 +118,7 @@ module "network-mount-target-nsg" {
118118
119119module "network-compute-admin-nsg" {
120120 source = " ./modules/network/nsg"
121- count = local. wls_subnet_cidr != " " ? 1 : 0
121+ count = ! local . use_existing_subnets && local. wls_subnet_cidr != " " ? 1 : 0
122122 compartment_id = local. network_compartment_id
123123 vcn_id = local. vcn_id
124124 nsg_name = " ${ local . service_name_prefix } -admin-server-nsg"
@@ -131,7 +131,7 @@ module "network-compute-admin-nsg" {
131131
132132module "network-compute-managed-nsg" {
133133 source = " ./modules/network/nsg"
134- count = local. wls_subnet_cidr != " " ? 1 : 0
134+ count = ! local . use_existing_subnets && local. wls_subnet_cidr != " " ? 1 : 0
135135 compartment_id = local. network_compartment_id
136136 vcn_id = local. vcn_id
137137 nsg_name = " ${ local . service_name_prefix } -managed-server-nsg"
@@ -169,8 +169,8 @@ module "network-bastion-subnet" {
169169 count = ! local. assign_weblogic_public_ip && var. bastion_subnet_id == " " && var. is_bastion_instance_required && var. existing_bastion_instance_id == " " ? 1 : 0
170170 compartment_id = local. network_compartment_id
171171 vcn_id = local. vcn_id
172- dhcp_options_id = module. network-vcn-config [0 ]. dhcp_options_id
173- route_table_id = module. network-vcn-config [0 ]. route_table_id
172+ dhcp_options_id = length ( module. network-vcn-config ) > 0 ? module . network-vcn-config [0 ]. dhcp_options_id : " "
173+ route_table_id = length ( module. network-vcn-config ) > 0 ? module . network-vcn-config [0 ]. route_table_id : " "
174174 subnet_name = " ${ local . service_name_prefix } -${ var . bastion_subnet_name } "
175175 dns_label = " ${ var . bastion_subnet_name } -${ substr (uuid (), - 7 , - 1 )} "
176176 cidr_block = local. bastion_subnet_cidr
@@ -236,7 +236,7 @@ module "bastion" {
236236 freeform_tags = local.free_form_tags
237237 }
238238 is_bastion_with_reserved_public_ip = var. is_bastion_with_reserved_public_ip
239- bastion_nsg_id = var. bastion_subnet_id != " " ? (var. add_existing_nsg ? [var . existing_bastion_nsg_id ] : []) : element (module. network-bastion-nsg [* ]. nsg_id , 0 )
239+ bastion_nsg_id = var. bastion_subnet_id != " " ? (var. add_existing_nsg ? [var . existing_bastion_nsg_id ] : []) : flatten (module. network-bastion-nsg [* ]. nsg_id )
240240
241241 use_bastion_marketplace_image = var. use_bastion_marketplace_image
242242 mp_listing_id = var. bastion_listing_id
0 commit comments