diff --git a/templates/complete_multi_region/locals-config.tf b/templates/complete_multi_region/locals-config.tf index 5b12b3a4..f0e23fe2 100644 --- a/templates/complete_multi_region/locals-config.tf +++ b/templates/complete_multi_region/locals-config.tf @@ -46,4 +46,4 @@ locals { subscription_id_identity = var.subscription_id_identity subscription_id_management = var.subscription_id_management } -} \ No newline at end of file +} diff --git a/templates/complete_multi_region/locals-resource-groups.tf b/templates/complete_multi_region/locals-resource-groups.tf index d71ca86a..7c20cec5 100644 --- a/templates/complete_multi_region/locals-resource-groups.tf +++ b/templates/complete_multi_region/locals-resource-groups.tf @@ -3,4 +3,4 @@ locals { connectivity_resource_groups_json_templated = templatestring(local.connectivity_resource_groups_json, local.config_template_file_variables) connectivity_resource_groups_json_final = replace(replace(local.connectivity_resource_groups_json_templated, "\"[", "["), "]\"", "]") connectivity_resource_groups = jsondecode(local.connectivity_resource_groups_json_final) -} \ No newline at end of file +} diff --git a/templates/complete_multi_region/locals.tf b/templates/complete_multi_region/locals.tf index 3a7dc480..84c2cb0f 100644 --- a/templates/complete_multi_region/locals.tf +++ b/templates/complete_multi_region/locals.tf @@ -9,6 +9,7 @@ locals { } locals { + management_enabled = (var.management_settings_es) > 0 connectivity_virtual_wan_enabled = var.connectivity_type == local.const.connectivity.virtual_wan connectivity_hub_and_spoke_vnet_enabled = var.connectivity_type == local.const.connectivity.hub_and_spoke_vnet connectivity_none_enabled = var.connectivity_type == local.const.connectivity.none diff --git a/templates/complete_multi_region/management.tf b/templates/complete_multi_region/management.tf index 5b0c7c4f..22b1eabb 100644 --- a/templates/complete_multi_region/management.tf +++ b/templates/complete_multi_region/management.tf @@ -1,7 +1,7 @@ module "management_groups" { source = "./modules/management-es" - count = var.management_use_avm ? 0 : 1 + count = !var.skip_deploy && var.management_use_avm ? 0 : 1 enable_telemetry = var.enable_telemetry settings = local.management_settings_es diff --git a/templates/complete_multi_region/modules/hub-and-spoke-vnet/locals.tf b/templates/complete_multi_region/modules/hub-and-spoke-vnet/locals.tf index 450e52bc..83dc56eb 100644 --- a/templates/complete_multi_region/modules/hub-and-spoke-vnet/locals.tf +++ b/templates/complete_multi_region/modules/hub-and-spoke-vnet/locals.tf @@ -22,7 +22,7 @@ locals { locals { private_dns_zones = { for key, value in var.hub_virtual_networks : key => merge({ location = value.hub_virtual_network.location - }, value.private_dns_zones) if can(value.private_dns_zones) } + }, value.private_dns_zones) if can(value.private_dns_zones.resource_group_name) } private_dns_zones_virtual_network_links = { for key, value in module.hub_and_spoke_vnet.virtual_networks : key => { @@ -52,6 +52,6 @@ locals { } locals { - ddos_protection_plan = can(var.hub_and_spoke_networks_settings.ddos_protection_plan) ? var.hub_and_spoke_networks_settings.ddos_protection_plan : null + 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_enabled = local.ddos_protection_plan != null } diff --git a/templates/complete_multi_region/modules/hub-and-spoke-vnet/outputs.tf b/templates/complete_multi_region/modules/hub-and-spoke-vnet/outputs.tf deleted file mode 100644 index 7a7fd518..00000000 --- a/templates/complete_multi_region/modules/hub-and-spoke-vnet/outputs.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "virtual_networks" { - value = { - for key, value in module.hub_and_spoke_vnet.virtual_networks : key => { - resource_id = value.id - } - } -} diff --git a/templates/complete_multi_region/modules/hub-and-spoke-vnet/terraform.tf b/templates/complete_multi_region/modules/hub-and-spoke-vnet/terraform.tf index 4619009c..d6c95626 100644 --- a/templates/complete_multi_region/modules/hub-and-spoke-vnet/terraform.tf +++ b/templates/complete_multi_region/modules/hub-and-spoke-vnet/terraform.tf @@ -10,5 +10,4 @@ terraform { version = "~> 1.13" } } - # backend "azurerm" {} } diff --git a/templates/complete_multi_region/modules/management-es/main.tf b/templates/complete_multi_region/modules/management-es/main.tf index 4c7694a9..3ea1a33a 100644 --- a/templates/complete_multi_region/modules/management-es/main.tf +++ b/templates/complete_multi_region/modules/management-es/main.tf @@ -47,4 +47,4 @@ module "management_groups" { azurerm.connectivity = azurerm.connectivity azurerm.management = azurerm.management } -} \ No newline at end of file +} diff --git a/templates/complete_multi_region/modules/management-es/terraform.tf b/templates/complete_multi_region/modules/management-es/terraform.tf index 0417ea7c..f5314d87 100644 --- a/templates/complete_multi_region/modules/management-es/terraform.tf +++ b/templates/complete_multi_region/modules/management-es/terraform.tf @@ -1,4 +1,5 @@ terraform { + required_version = "~> 1.9" required_providers { azurerm = { source = "hashicorp/azurerm" @@ -9,4 +10,4 @@ terraform { ] } } -} \ No newline at end of file +} diff --git a/templates/complete_multi_region/modules/management-es/variables.tf b/templates/complete_multi_region/modules/management-es/variables.tf index cd630d30..bc3fc55b 100644 --- a/templates/complete_multi_region/modules/management-es/variables.tf +++ b/templates/complete_multi_region/modules/management-es/variables.tf @@ -5,4 +5,4 @@ variable "settings" { variable "enable_telemetry" { type = bool default = true -} \ No newline at end of file +} diff --git a/templates/complete_multi_region/modules/virtual-wan/locals.tf b/templates/complete_multi_region/modules/virtual-wan/locals.tf index 7218f49e..cea6ab29 100644 --- a/templates/complete_multi_region/modules/virtual-wan/locals.tf +++ b/templates/complete_multi_region/modules/virtual-wan/locals.tf @@ -50,7 +50,7 @@ locals { locals { private_dns_zones = { for key, value in var.virtual_hubs : key => merge({ location = value.hub.location - }, value.private_dns_zones) if can(value.private_dns_zones) } + }, value.private_dns_zones) if can(value.private_dns_zones.resource_group_name) } private_dns_zones_virtual_network_links = { for key, value in module.virtual_network_private_dns : key => { @@ -80,6 +80,6 @@ locals { } locals { - ddos_protection_plan = can(var.virtual_wan_settings.ddos_protection_plan) ? var.virtual_wan_settings.ddos_protection_plan : null + ddos_protection_plan = can(var.virtual_wan_settings.ddos_protection_plan.name) ? var.virtual_wan_settings.ddos_protection_plan : null ddos_protection_plan_enabled = local.ddos_protection_plan != null } diff --git a/templates/complete_multi_region/modules/virtual-wan/outputs.tf b/templates/complete_multi_region/modules/virtual-wan/outputs.tf deleted file mode 100644 index c6585b91..00000000 --- a/templates/complete_multi_region/modules/virtual-wan/outputs.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "private_dns_zones_virtual_networks" { - value = { - for key, value in module.virtual_network_private_dns : key => { - resource_id = value.resource_id - } - } -} \ No newline at end of file diff --git a/templates/complete_multi_region/modules/virtual-wan/terraform.tf b/templates/complete_multi_region/modules/virtual-wan/terraform.tf index 28d0feae..d6c95626 100644 --- a/templates/complete_multi_region/modules/virtual-wan/terraform.tf +++ b/templates/complete_multi_region/modules/virtual-wan/terraform.tf @@ -1,5 +1,5 @@ terraform { - required_version = "~> 1.8" + required_version = "~> 1.9" required_providers { azurerm = { source = "hashicorp/azurerm" @@ -10,5 +10,4 @@ terraform { version = "~> 1.13" } } - # backend "azurerm" {} } diff --git a/templates/complete_multi_region/networking-hub-and-spoke-vnet.tf b/templates/complete_multi_region/networking-hub-and-spoke-vnet.tf index cd9d137d..7039a75a 100644 --- a/templates/complete_multi_region/networking-hub-and-spoke-vnet.tf +++ b/templates/complete_multi_region/networking-hub-and-spoke-vnet.tf @@ -1,7 +1,7 @@ module "hub_and_spoke_vnet" { source = "./modules/hub-and-spoke-vnet" - count = local.connectivity_hub_and_spoke_vnet_enabled ? 1 : 0 + count = !var.skip_deploy && local.connectivity_hub_and_spoke_vnet_enabled ? 1 : 0 hub_and_spoke_networks_settings = local.hub_and_spoke_vnet_settings hub_virtual_networks = local.hub_and_spoke_vnet_virtual_networks diff --git a/templates/complete_multi_region/networking-virtual-wan.tf b/templates/complete_multi_region/networking-virtual-wan.tf index 4bf75949..c5a0fb36 100644 --- a/templates/complete_multi_region/networking-virtual-wan.tf +++ b/templates/complete_multi_region/networking-virtual-wan.tf @@ -1,7 +1,7 @@ module "virtual_wan" { source = "./modules/virtual-wan" - count = local.connectivity_virtual_wan_enabled ? 1 : 0 + count = !var.skip_deploy && local.connectivity_virtual_wan_enabled ? 1 : 0 virtual_wan_settings = local.virtual_wan_settings virtual_hubs = local.virtual_wan_virtual_hubs @@ -15,4 +15,4 @@ module "virtual_wan" { module.management_groups, module.resource_groups ] -} \ No newline at end of file +} diff --git a/templates/complete_multi_region/resource-groups.tf b/templates/complete_multi_region/resource-groups.tf index adaba836..e7698e25 100644 --- a/templates/complete_multi_region/resource-groups.tf +++ b/templates/complete_multi_region/resource-groups.tf @@ -2,7 +2,7 @@ module "resource_groups" { source = "Azure/avm-res-resources-resourcegroup/azurerm" version = "0.1.0" - for_each = local.connectivity_resource_groups + for_each = var.skip_deploy ? {} : local.connectivity_resource_groups name = each.value.name location = each.value.location diff --git a/templates/complete_multi_region/terraform.tf b/templates/complete_multi_region/terraform.tf index 788d0588..c4fe252d 100644 --- a/templates/complete_multi_region/terraform.tf +++ b/templates/complete_multi_region/terraform.tf @@ -1,5 +1,5 @@ terraform { - required_version = "~> 1.8" + required_version = "~> 1.9" required_providers { azurerm = { source = "hashicorp/azurerm" diff --git a/templates/complete_multi_region/variables.management.tf b/templates/complete_multi_region/variables-management.tf similarity index 99% rename from templates/complete_multi_region/variables.management.tf rename to templates/complete_multi_region/variables-management.tf index 630a97fa..5b9e58b9 100644 --- a/templates/complete_multi_region/variables.management.tf +++ b/templates/complete_multi_region/variables-management.tf @@ -12,4 +12,4 @@ variable "management_settings_avm" { variable "management_settings_es" { type = any default = {} -} \ No newline at end of file +} diff --git a/templates/complete_multi_region/variables.tf b/templates/complete_multi_region/variables.tf index c4503363..a4ca2bee 100644 --- a/templates/complete_multi_region/variables.tf +++ b/templates/complete_multi_region/variables.tf @@ -35,3 +35,9 @@ variable "enable_telemetry" { default = true description = "Flag to enable/disable telemetry" } + +variable "skip_deploy" { + type = bool + default = false + description = "Flag to skip deployment. This is used for testing and documentation generation purposes." +} \ No newline at end of file