Skip to content

Commit

Permalink
Tidy up
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredfholgate committed Oct 8, 2024
1 parent 2723dd1 commit 7d2fa28
Show file tree
Hide file tree
Showing 19 changed files with 25 additions and 33 deletions.
2 changes: 1 addition & 1 deletion templates/complete_multi_region/locals-config.tf
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ locals {
subscription_id_identity = var.subscription_id_identity
subscription_id_management = var.subscription_id_management
}
}
}
2 changes: 1 addition & 1 deletion templates/complete_multi_region/locals-resource-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
1 change: 1 addition & 0 deletions templates/complete_multi_region/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/complete_multi_region/management.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ terraform {
version = "~> 1.13"
}
}
# backend "azurerm" {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ module "management_groups" {
azurerm.connectivity = azurerm.connectivity
azurerm.management = azurerm.management
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
terraform {
required_version = "~> 1.9"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
Expand All @@ -9,4 +10,4 @@ terraform {
]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ variable "settings" {
variable "enable_telemetry" {
type = bool
default = true
}
}
4 changes: 2 additions & 2 deletions templates/complete_multi_region/modules/virtual-wan/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = "~> 1.8"
required_version = "~> 1.9"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
Expand All @@ -10,5 +10,4 @@ terraform {
version = "~> 1.13"
}
}
# backend "azurerm" {}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions templates/complete_multi_region/networking-virtual-wan.tf
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,4 +15,4 @@ module "virtual_wan" {
module.management_groups,
module.resource_groups
]
}
}
2 changes: 1 addition & 1 deletion templates/complete_multi_region/resource-groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion templates/complete_multi_region/terraform.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
terraform {
required_version = "~> 1.8"
required_version = "~> 1.9"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ variable "management_settings_avm" {
variable "management_settings_es" {
type = any
default = {}
}
}
6 changes: 6 additions & 0 deletions templates/complete_multi_region/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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."
}

0 comments on commit 7d2fa28

Please sign in to comment.