Skip to content

Commit

Permalink
Fix sub resource checks
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Nov 29, 2024
1 parent d9b4bb5 commit 5936c47
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
bastions_enabled = { for key, value in var.hub_virtual_networks : key => can(value.bastion) }
bastions_enabled = { for key, value in var.hub_virtual_networks : key => try(value.bastion, null) != null }
}

locals {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
locals {
ddos_protection_plan = can(var.hub_and_spoke_networks_settings.ddos_protection_plan.name) ? var.hub_and_spoke_networks_settings.ddos_protection_plan : null
ddos_protection_plan = try(var.hub_and_spoke_networks_settings.ddos_protection_plan.name, null) != null ? var.hub_and_spoke_networks_settings.ddos_protection_plan : null
ddos_protection_plan_enabled = local.ddos_protection_plan != null
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
private_dns_zones_enabled = { for key, value in var.hub_virtual_networks : key => can(value.private_dns_zones) }
private_dns_zones_enabled = { for key, value in var.hub_virtual_networks : key => try(value.private_dns_zones, null) != null }
}

locals {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ locals {
virtual_network_gateway = merge({
type = "ExpressRoute"
}, hub_network_value.virtual_network_gateways.express_route)
} if can(hub_network_value.virtual_network_gateways.express_route)
} if try(hub_network_value.virtual_network_gateways.express_route, null) != null
}
virtual_network_gateways_vpn = {
for hub_network_key, hub_network_value in var.hub_virtual_networks : "${hub_network_key}-vpn" => {
hub_network_key = hub_network_key
virtual_network_gateway = merge({
type = "Vpn"
}, hub_network_value.virtual_network_gateways.vpn)
} if can(hub_network_value.virtual_network_gateways.vpn)
} if try(hub_network_value.virtual_network_gateways.vpn, null) != null
}
virtual_network_gateways = merge(local.virtual_network_gateways_express_route, local.virtual_network_gateways_vpn)
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ locals {
route_table = {
assign_generated_route_table = false
}
} } if can(value.virtual_network_gateways.express_route) || can(value.virtual_network_gateways.vpn)
} } if try(value.virtual_network_gateways, null) != null && (can(value.virtual_network_gateways.express_route) || can(value.virtual_network_gateways.vpn))
}

subnets = { for key, value in var.hub_virtual_networks : key => merge(local.private_dns_resolver_subnets[key], local.bastion_subnets[key], local.gateway_subnets[key]) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
bastions_enabled = { for key, value in var.virtual_hubs : key => can(value.bastion) }
bastions_enabled = { for key, value in var.virtual_hubs : key => try(value.bastion, null) != null }
}

locals {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
locals {
ddos_protection_plan = can(var.virtual_wan_settings.ddos_protection_plan.name) ? var.virtual_wan_settings.ddos_protection_plan : null
ddos_protection_plan = try(var.virtual_wan_settings.ddos_protection_plan.name, null) != null ? var.virtual_wan_settings.ddos_protection_plan : null
ddos_protection_plan_enabled = local.ddos_protection_plan != null
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
private_dns_zones_enabled = { for key, value in var.virtual_hubs : key => can(value.private_dns_zones) }
private_dns_zones_enabled = { for key, value in var.virtual_hubs : key => try(value.private_dns_zones, null) != null }
}

locals {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
side_car_virtual_networks_enabled = { for key, value in var.virtual_hubs : key => can(value.side_car_virtual_network) }
side_car_virtual_networks_enabled = { for key, value in var.virtual_hubs : key => try(value.side_car_virtual_network, null) != null }
}

locals {
Expand Down

0 comments on commit 5936c47

Please sign in to comment.