From 375388a7fc8f2904994ff42cc3830bb21808dc22 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Sat, 28 Sep 2024 16:47:51 +0100 Subject: [PATCH 1/5] Update config for removing ui and multi-region --- templates/basic/main.tf | 6 +- templates/basic/variables.tf | 18 +- templates/complete/locals.tf | 5 +- templates/complete/main.tf | 2 +- templates/complete/variables.tf | 18 +- templates/complete_multi_region/variables.tf | 14 +- templates/complete_vnext/locals.tf | 5 +- templates/complete_vnext/main.tf | 200 +------------------ templates/complete_vnext/variables.tf | 18 +- templates/hubnetworking/main.tf | 18 +- templates/hubnetworking/variables.tf | 26 +-- templates/test/main.tf | 16 +- templates/test/variables.tf | 16 +- 13 files changed, 91 insertions(+), 271 deletions(-) diff --git a/templates/basic/main.tf b/templates/basic/main.tf index 589b6ca3..7f0e696a 100644 --- a/templates/basic/main.tf +++ b/templates/basic/main.tf @@ -1,10 +1,14 @@ +locals { + starter_location = var.starter_locations[0] +} + module "enterprise_scale" { source = "Azure/caf-enterprise-scale/azurerm" version = "~> 6.0.0" disable_telemetry = true - default_location = var.starter_location + default_location = local.starter_location root_parent_id = var.root_parent_management_group_id == "" ? data.azurerm_client_config.current.tenant_id : var.root_parent_management_group_id deploy_corp_landing_zones = true diff --git a/templates/basic/variables.tf b/templates/basic/variables.tf index 6d2b2134..c2377050 100644 --- a/templates/basic/variables.tf +++ b/templates/basic/variables.tf @@ -1,37 +1,37 @@ -variable "starter_location" { - type = string - description = "The location for Azure resources. (e.g 'uksouth')|1|azure_location" +variable "starter_locations" { + type = list(string) + description = "The location for Azure resources. (e.g 'uksouth')|azure_location" } variable "subscription_id_connectivity" { type = string - description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|3|azure_subscription_id" + description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" } variable "subscription_id_identity" { type = string - description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|4|azure_subscription_id" + description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" } variable "subscription_id_management" { type = string - description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|5|azure_subscription_id" + description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|azure_subscription_id" } variable "root_id" { type = string default = "es" - description = "The root id is the identity for the root management group and a prefix applied to all management group identities|6|azure_name" + description = "The root id is the identity for the root management group and a prefix applied to all management group identities|azure_name" } variable "root_name" { type = string default = "Enterprise-Scale" - description = "The display name for the root management group|7|azure_name" + description = "The display name for the root management group|azure_name" } variable "root_parent_management_group_id" { type = string default = "" - description = "The parent management group id. Defaults to `Tenant Root Group` if not supplied.|2" + description = "The parent management group id. Defaults to `Tenant Root Group` if not supplied." } diff --git a/templates/complete/locals.tf b/templates/complete/locals.tf index 5ab68584..3aea5ce6 100644 --- a/templates/complete/locals.tf +++ b/templates/complete/locals.tf @@ -1,3 +1,6 @@ +locals { + starter_location = var.starter_locations[0] +} locals { config_file_extension = replace(lower(element(local.config_file_split, length(local.config_file_split) - 1)), local.const_yml, local.const_yaml) config_file_name = var.configuration_file_path == "" ? "config.yaml" : basename(var.configuration_file_path) @@ -11,7 +14,7 @@ locals { jsondecode(templatefile("${path.module}/${local.config_file_name}", local.config_template_file_variables)) ) config_template_file_variables = { - starter_location = var.starter_location + starter_location = local.starter_location default_postfix = var.default_postfix root_parent_management_group_id = var.root_parent_management_group_id == "" ? data.azurerm_client_config.core.tenant_id : var.root_parent_management_group_id subscription_id_connectivity = var.subscription_id_connectivity diff --git a/templates/complete/main.tf b/templates/complete/main.tf index 0cf24902..f01b7845 100644 --- a/templates/complete/main.tf +++ b/templates/complete/main.tf @@ -5,7 +5,7 @@ module "enterprise_scale" { count = length(local.archetypes) > 0 ? 1 : 0 disable_telemetry = try(local.archetypes.disable_telemetry, true) - default_location = try(local.archetypes.default_location, var.starter_location) + default_location = try(local.archetypes.default_location, local.starter_location) root_parent_id = try(local.archetypes.root_parent_id, data.azurerm_client_config.core.tenant_id) archetype_config_overrides = try(local.archetypes.archetype_config_overrides, {}) configure_connectivity_resources = try(local.archetypes.configure_connectivity_resources, {}) diff --git a/templates/complete/variables.tf b/templates/complete/variables.tf index 6cd36744..37321ca5 100644 --- a/templates/complete/variables.tf +++ b/templates/complete/variables.tf @@ -1,37 +1,37 @@ -variable "starter_location" { - type = string - description = "The location for Azure resources. (e.g 'uksouth')|1|azure_location" +variable "starter_locations" { + type = list(string) + description = "The location for Azure resources. (e.g 'uksouth')|azure_location" } variable "subscription_id_connectivity" { type = string - description = "value of the subscription id for the Connectivity subscription|5|azure_subscription_id" + description = "value of the subscription id for the Connectivity subscription|azure_subscription_id" } variable "subscription_id_identity" { type = string - description = "value of the subscription id for the Identity subscription|6|azure_subscription_id" + description = "value of the subscription id for the Identity subscription|azure_subscription_id" } variable "subscription_id_management" { type = string - description = "value of the subscription id for the Management subscription|4|azure_subscription_id" + description = "value of the subscription id for the Management subscription|azure_subscription_id" } variable "configuration_file_path" { type = string default = "" - description = "The path of the configuration file|7|configuration_file_path" + description = "The path of the configuration file|configuration_file_path" } variable "default_postfix" { type = string default = "landing-zone" - description = "The default postfix for Azure resources. (e.g 'landing-zone')|2|azure_name" + description = "The default postfix for Azure resources. (e.g 'landing-zone')|azure_name" } variable "root_parent_management_group_id" { type = string default = "" - description = "This is the id of the management group that the ALZ hierarchy will be nested under, will default to the Tenant Root Group|3|azure_name" + description = "This is the id of the management group that the ALZ hierarchy will be nested under, will default to the Tenant Root Group|azure_name" } diff --git a/templates/complete_multi_region/variables.tf b/templates/complete_multi_region/variables.tf index edd7584a..1cf7e06d 100644 --- a/templates/complete_multi_region/variables.tf +++ b/templates/complete_multi_region/variables.tf @@ -1,37 +1,37 @@ variable "starter_locations" { type = list(string) - description = "The location for Azure resources. (e.g 'uksouth')|1|azure_location" + description = "The location for Azure resources. (e.g 'uksouth')|azure_location" } variable "subscription_id_connectivity" { type = string - description = "value of the subscription id for the Connectivity subscription|5|azure_subscription_id" + description = "value of the subscription id for the Connectivity subscription|azure_subscription_id" } variable "subscription_id_identity" { type = string - description = "value of the subscription id for the Identity subscription|6|azure_subscription_id" + description = "value of the subscription id for the Identity subscription|azure_subscription_id" } variable "subscription_id_management" { type = string - description = "value of the subscription id for the Management subscription|4|azure_subscription_id" + description = "value of the subscription id for the Management subscription|azure_subscription_id" } variable "configuration_file_path" { type = string default = "config-hub-and-spoke-vnet.yaml" - description = "The path of the configuration file|7|configuration_file_path" + description = "The path of the configuration file|configuration_file_path" } variable "default_postfix" { type = string default = "landing-zone" - description = "The default postfix for Azure resources. (e.g 'landing-zone')|2|azure_name" + description = "The default postfix for Azure resources. (e.g 'landing-zone')|azure_name" } variable "root_parent_management_group_id" { type = string default = "" - description = "This is the id of the management group that the ALZ hierarchy will be nested under, will default to the Tenant Root Group|3|azure_name" + description = "This is the id of the management group that the ALZ hierarchy will be nested under, will default to the Tenant Root Group|azure_name" } diff --git a/templates/complete_vnext/locals.tf b/templates/complete_vnext/locals.tf index 21ed2865..64b6b9b1 100644 --- a/templates/complete_vnext/locals.tf +++ b/templates/complete_vnext/locals.tf @@ -1,3 +1,6 @@ +locals { + starter_location = var.starter_locations[0] +} locals { config_file_extension = replace(lower(element(local.config_file_split, length(local.config_file_split) - 1)), local.const_yml, local.const_yaml) config_file_name = var.configuration_file_path == "" ? "config.yaml" : basename(var.configuration_file_path) @@ -11,7 +14,7 @@ locals { jsondecode(templatefile("${path.module}/${local.config_file_name}", local.config_template_file_variables)) ) config_template_file_variables = { - default_location = var.default_location + default_location = local.starter_location default_postfix = var.default_postfix root_parent_management_group_id = var.root_parent_management_group_id == "" ? data.azurerm_client_config.core.tenant_id : var.root_parent_management_group_id subscription_id_connectivity = var.subscription_id_connectivity diff --git a/templates/complete_vnext/main.tf b/templates/complete_vnext/main.tf index d298daff..2676d01f 100644 --- a/templates/complete_vnext/main.tf +++ b/templates/complete_vnext/main.tf @@ -1,199 +1 @@ -module "management_resources" { - source = "Azure/avm-ptn-alz-management/azurerm" - version = "~> 0.1.0" - - automation_account_name = try(local.management.automation_account_name, "") - location = try(local.management.location, "") - log_analytics_workspace_name = try(local.management.log_analytics_workspace_name, "") - resource_group_name = try(local.management.resource_group_name, "") - enable_telemetry = false - - providers = { - azurerm = azurerm.management - } -} - -module "management_groups_layer_1" { - source = "Azure/avm-ptn-alz/azurerm" - version = "~> 0.6.0" - for_each = local.management_groups_layer_1 - id = each.value.id - display_name = each.value.display_name - parent_resource_id = each.value.parent_resource_id - base_archetype = each.value.base_archetype - default_location = var.default_location - default_log_analytics_workspace_id = local.log_analytics_workspace_id - subscription_ids = each.value.subscriptions -} - -module "management_groups_layer_2" { - source = "Azure/avm-ptn-alz/azurerm" - version = "~> 0.6.0" - for_each = local.management_groups_layer_2 - id = each.value.id - display_name = each.value.display_name - parent_resource_id = module.management_groups_layer_1[each.value.parent].management_group_resource_id - base_archetype = each.value.base_archetype - default_location = var.default_location - default_log_analytics_workspace_id = local.log_analytics_workspace_id - subscription_ids = each.value.subscriptions -} - -module "management_groups_layer_3" { - source = "Azure/avm-ptn-alz/azurerm" - version = "~> 0.6.0" - for_each = local.management_groups_layer_3 - id = each.value.id - display_name = each.value.display_name - parent_resource_id = module.management_groups_layer_2[each.value.parent].management_group_resource_id - base_archetype = each.value.base_archetype - default_location = var.default_location - default_log_analytics_workspace_id = local.log_analytics_workspace_id - subscription_ids = each.value.subscriptions -} - -module "management_groups_layer_4" { - source = "Azure/avm-ptn-alz/azurerm" - version = "~> 0.6.0" - for_each = local.management_groups_layer_4 - id = each.value.id - display_name = each.value.display_name - parent_resource_id = module.management_groups_layer_3[each.value.parent].management_group_resource_id - base_archetype = each.value.base_archetype - default_location = var.default_location - default_log_analytics_workspace_id = local.log_analytics_workspace_id - subscription_ids = each.value.subscriptions -} - -module "management_groups_layer_5" { - source = "Azure/avm-ptn-alz/azurerm" - version = "~> 0.6.0" - for_each = local.management_groups_layer_5 - id = each.value.id - display_name = each.value.display_name - parent_resource_id = module.management_groups_layer_4[each.value.parent].management_group_resource_id - base_archetype = each.value.base_archetype - default_location = var.default_location - default_log_analytics_workspace_id = local.log_analytics_workspace_id - subscription_ids = each.value.subscriptions -} - -module "management_groups_layer_6" { - source = "Azure/avm-ptn-alz/azurerm" - version = "~> 0.6.0" - for_each = local.management_groups_layer_6 - id = each.value.id - display_name = each.value.display_name - parent_resource_id = module.management_groups_layer_5[each.value.parent].management_group_resource_id - base_archetype = each.value.base_archetype - default_location = var.default_location - default_log_analytics_workspace_id = local.log_analytics_workspace_id - subscription_ids = each.value.subscriptions -} - -module "management_groups_layer_7" { - source = "Azure/avm-ptn-alz/azurerm" - version = "~> 0.6.0" - for_each = local.management_groups_layer_7 - id = each.value.id - display_name = each.value.display_name - parent_resource_id = module.management_groups_layer_6[each.value.parent].management_group_resource_id - base_archetype = each.value.base_archetype - default_location = var.default_location - default_log_analytics_workspace_id = local.log_analytics_workspace_id - subscription_ids = each.value.subscriptions -} - - -module "hubnetworking" { - source = "Azure/hubnetworking/azurerm" - version = "~> 1.1.1" - - count = length(local.hub_virtual_networks) > 0 ? 1 : 0 - - hub_virtual_networks = local.module_hubnetworking.hub_virtual_networks - - providers = { - azurerm = azurerm.connectivity - } - - depends_on = [ - module.management_groups_layer_7 - ] -} - -module "virtual_network_gateway" { - source = "Azure/avm-ptn-vnetgateway/azurerm" - version = "~> 0.3.0" - - for_each = local.module_virtual_network_gateway - - location = each.value.location - name = each.value.name - sku = try(each.value.sku, null) - type = try(each.value.type, null) - virtual_network_id = each.value.virtual_network_id - default_tags = try(each.value.default_tags, null) - subnet_creation_enabled = try(each.value.subnet_creation_enabled, null) - edge_zone = try(each.value.edge_zone, null) - enable_telemetry = false - express_route_circuits = try(each.value.express_route_circuits, null) - ip_configurations = try(each.value.ip_configurations, null) - local_network_gateways = try(each.value.local_network_gateways, null) - subnet_address_prefix = try(each.value.subnet_address_prefix, null) - tags = try(each.value.tags, null) - vpn_active_active_enabled = try(each.value.vpn_active_active_enabled, null) - vpn_bgp_enabled = try(each.value.vpn_bgp_enabled, null) - vpn_bgp_settings = try(each.value.vpn_bgp_settings, null) - vpn_generation = try(each.value.vpn_generation, null) - vpn_point_to_site = try(each.value.vpn_point_to_site, null) - vpn_type = try(each.value.vpn_type, null) - vpn_private_ip_address_enabled = try(each.value.vpn_private_ip_address_enabled, null) - route_table_bgp_route_propagation_enabled = try(each.value.route_table_bgp_route_propagation_enabled, null) - route_table_creation_enabled = try(each.value.route_table_creation_enabled, null) - route_table_name = try(each.value.route_table_name, null) - route_table_tags = try(each.value.route_table_tags, null) - - providers = { - azurerm = azurerm.connectivity - } -} - -module "vwan" { - source = "Azure/avm-ptn-virtualwan/azurerm" - version = "~> 0.5.0" - - count = length(local.module_vwan) > 0 ? 1 : 0 - - allow_branch_to_branch_traffic = try(local.module_vwan.allow_branch_to_branch_traffic, null) - create_resource_group = try(local.module_vwan.create_resource_group, null) - disable_vpn_encryption = try(local.module_vwan.disable_vpn_encryption, null) - enable_telemetry = try(local.module_vwan.enable_telemetry, null) - er_circuit_connections = try(local.module_vwan.er_circuit_connections, null) - expressroute_gateways = try(local.module_vwan.expressroute_gateways, null) - firewalls = try(local.module_vwan.firewalls, null) - office365_local_breakout_category = try(local.module_vwan.office365_local_breakout_category, null) - location = try(local.module_vwan.location, null) - p2s_gateway_vpn_server_configurations = try(local.module_vwan.p2s_gateway_vpn_server_configurations, null) - p2s_gateways = try(local.module_vwan.p2s_gateways, null) - resource_group_name = try(local.module_vwan.resource_group_name, null) - virtual_hubs = try(local.module_vwan.virtual_hubs, null) - virtual_network_connections = try(local.module_vwan.virtual_network_connections, null) - virtual_wan_name = try(local.module_vwan.virtual_wan_name, null) - type = try(local.module_vwan.type, null) - routing_intents = try(local.module_vwan.routing_intents, null) - resource_group_tags = try(local.module_vwan.resource_group_tags, null) - virtual_wan_tags = try(local.module_vwan.virtual_wan_tags, null) - vpn_gateways = try(local.module_vwan.vpn_gateways, null) - vpn_site_connections = try(local.module_vwan.vpn_site_connections, null) - vpn_sites = try(local.module_vwan.vpn_sites, null) - tags = try(local.module_vwan.tags, null) - - providers = { - azurerm = azurerm.connectivity - } - - depends_on = [ - module.management_groups_layer_7 - ] -} +#TODO.. \ No newline at end of file diff --git a/templates/complete_vnext/variables.tf b/templates/complete_vnext/variables.tf index 23bfc6a2..318c2884 100644 --- a/templates/complete_vnext/variables.tf +++ b/templates/complete_vnext/variables.tf @@ -1,37 +1,37 @@ -variable "default_location" { - type = string - description = "The location for Azure resources. (e.g 'uksouth')|1|azure_location" +variable "starter_locations" { + type = list(string) + description = "The location for Azure resources. (e.g 'uksouth')|azure_location" } variable "subscription_id_connectivity" { type = string - description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|4|azure_subscription_id" + description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" } variable "subscription_id_identity" { type = string - description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|5|azure_subscription_id" + description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" } variable "subscription_id_management" { type = string - description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|6|azure_subscription_id" + description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|azure_subscription_id" } variable "configuration_file_path" { type = string default = "" - description = "The path of the configuration file|7|configuration_file_path" + description = "The path of the configuration file|configuration_file_path" } variable "default_postfix" { type = string default = "landing-zone" - description = "The default postfix for Azure resources. (e.g 'landing-zone')|2|azure_name" + description = "The default postfix for Azure resources. (e.g 'landing-zone')|azure_name" } variable "root_parent_management_group_id" { type = string default = "" - description = "The identifier of the Tenant Root Management Group, if left blank will use the tenant id. (e.g '00000000-0000-0000-0000-000000000000')|3|azure_name" + description = "The identifier of the Tenant Root Management Group, if left blank will use the tenant id. (e.g '00000000-0000-0000-0000-000000000000')|azure_name" } diff --git a/templates/hubnetworking/main.tf b/templates/hubnetworking/main.tf index a22bb489..fd102ef2 100644 --- a/templates/hubnetworking/main.tf +++ b/templates/hubnetworking/main.tf @@ -1,10 +1,14 @@ +locals { + starter_location = var.starter_locations[0] +} + module "enterprise_scale" { source = "Azure/caf-enterprise-scale/azurerm" version = "~> 6.0.0" disable_telemetry = true - default_location = var.starter_location + default_location = local.starter_location root_parent_id = var.root_parent_management_group_id == "" ? data.azurerm_client_config.current.tenant_id : var.root_parent_management_group_id deploy_corp_landing_zones = true @@ -29,10 +33,10 @@ module "hubnetworking" { hub_virtual_networks = { primary-hub = { - name = "vnet-hub-${var.starter_location}" + name = "vnet-hub-${local.starter_location}" address_space = [var.hub_virtual_network_address_prefix] - location = var.starter_location - resource_group_name = "rg-connectivity-${var.starter_location}" + location = local.starter_location + resource_group_name = "rg-connectivity-${local.starter_location}" firewall = { subnet_address_prefix = var.firewall_subnet_address_prefix sku_tier = "Standard" @@ -41,7 +45,7 @@ module "hubnetworking" { default_ip_configuration = { public_ip_config = { zones = ["1", "2", "3"] - name = "pip-hub-${var.starter_location}" + name = "pip-hub-${local.starter_location}" } } } @@ -63,8 +67,8 @@ module "virtual_network_gateway" { count = var.virtual_network_gateway_creation_enabled ? 1 : 0 - location = var.starter_location - name = "vgw-hub-${var.starter_location}" + location = local.starter_location + name = "vgw-hub-${local.starter_location}" subnet_address_prefix = var.gateway_subnet_address_prefix enable_telemetry = false virtual_network_id = module.hubnetworking.virtual_networks["primary-hub"].id diff --git a/templates/hubnetworking/variables.tf b/templates/hubnetworking/variables.tf index afd2d776..51ee5bdc 100644 --- a/templates/hubnetworking/variables.tf +++ b/templates/hubnetworking/variables.tf @@ -1,58 +1,58 @@ -variable "starter_location" { - description = "The location for Azure resources. (e.g 'uksouth')|1|azure_location" - type = string +variable "starter_locations" { + description = "The location for Azure resources. (e.g 'uksouth')|azure_location" + type = list(string) } variable "root_parent_management_group_id" { - description = "The parent management group id. Defaults to `Tenant Root Group` if not supplied.|2" + description = "The parent management group id. Defaults to `Tenant Root Group` if not supplied." type = string default = "" } variable "subscription_id_connectivity" { - description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|3|azure_subscription_id" + description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" type = string } variable "subscription_id_identity" { - description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|4|azure_subscription_id" + description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" type = string } variable "subscription_id_management" { - description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|5|azure_subscription_id" + description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|azure_subscription_id" type = string } variable "root_id" { - description = "The root id is the identity for the root management group and a prefix applied to all management group identities|6|azure_name" + description = "The root id is the identity for the root management group and a prefix applied to all management group identities|azure_name" type = string default = "es" } variable "root_name" { - description = "The display name for the root management group|7|azure_name" + description = "The display name for the root management group|azure_name" type = string default = "Enterprise-Scale" } variable "hub_virtual_network_address_prefix" { - description = "The IP address range for the hub network in CIDR format|8|cidr_range" + description = "The IP address range for the hub network in CIDR format|cidr_range" type = string } variable "firewall_subnet_address_prefix" { - description = "The IP address range for the firewall subnet in CIDR format|9|cidr_range" + description = "The IP address range for the firewall subnet in CIDR format|cidr_range" type = string } variable "gateway_subnet_address_prefix" { - description = "The IP address range for the gateway subnet in CIDR format|10|cidr_range" + description = "The IP address range for the gateway subnet in CIDR format|cidr_range" type = string } variable "virtual_network_gateway_creation_enabled" { - description = "Whether the virtual network gateway is created|11|bool" + description = "Whether the virtual network gateway is created" type = bool default = false } diff --git a/templates/test/main.tf b/templates/test/main.tf index 4f613f9c..59ec4f6a 100644 --- a/templates/test/main.tf +++ b/templates/test/main.tf @@ -5,6 +5,10 @@ data "azurerm_management_group" "example_parent" { name = var.root_parent_management_group_id == "" ? data.azurerm_client_config.current.tenant_id : var.root_parent_management_group_id } +locals { + starter_location = var.starter_locations[0] +} + resource "random_string" "example" { length = 10 special = false @@ -21,26 +25,26 @@ resource "azurerm_management_group" "example_child" { resource "azurerm_resource_group" "management" { provider = azurerm.management name = "e2e-test-management-azurerm-${random_string.example.result}" - location = var.starter_location + location = local.starter_location } resource "azurerm_resource_group" "connectivity" { provider = azurerm.connectivity name = "e2e-test-connectivity-azurerm-${random_string.example.result}" - location = var.starter_location + location = local.starter_location } resource "azurerm_resource_group" "identity" { provider = azurerm.identity name = "e2e-test-identity-azurerm-${random_string.example.result}" - location = var.starter_location + location = local.starter_location } resource "azapi_resource" "resource_group_management" { parent_id = "/subscriptions/${var.subscription_id_management}" type = "Microsoft.Resources/resourceGroups@2021-04-01" name = "e2e-test-management-azapi-${random_string.example.result}" - location = var.starter_location + location = local.starter_location body = { properties = {} } @@ -51,7 +55,7 @@ resource "azapi_resource" "resource_group_connectivity" { parent_id = "/subscriptions/${var.subscription_id_connectivity}" type = "Microsoft.Resources/resourceGroups@2021-04-01" name = "e2e-test-connectivity-azapi-${random_string.example.result}" - location = var.starter_location + location = local.starter_location body = { properties = {} } @@ -62,7 +66,7 @@ resource "azapi_resource" "resource_group_identity" { parent_id = "/subscriptions/${var.subscription_id_identity}" type = "Microsoft.Resources/resourceGroups@2021-04-01" name = "e2e-test-identity-azapi-${random_string.example.result}" - location = var.starter_location + location = local.starter_location body = { properties = {} } diff --git a/templates/test/variables.tf b/templates/test/variables.tf index a826002b..72ebfcb4 100644 --- a/templates/test/variables.tf +++ b/templates/test/variables.tf @@ -1,32 +1,32 @@ variable "root_parent_management_group_id" { - description = "The parent management group for testing|1" + description = "The parent management group for testing" type = string default = "" } variable "subscription_id_connectivity" { - description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|2|azure_subscription_id" + description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" type = string } variable "subscription_id_identity" { - description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|3|azure_subscription_id" + description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" type = string } variable "subscription_id_management" { - description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|4|azure_subscription_id" + description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|azure_subscription_id" type = string } variable "child_management_group_display_name" { - description = "The child management group for testing display name|5" + description = "The child management group for testing display name" type = string default = "E2E Test" } -variable "starter_location" { - type = string - description = "This is the fourth test variable|6|azure_location" +variable "starter_locations" { + type = list(string) + description = "This is the fourth test variable|azure_location" default = "uksouth" } From 343dd091eab159e6baa04b3231b0e92342b825d1 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Mon, 30 Sep 2024 20:15:24 +0100 Subject: [PATCH 2/5] Fix test default region variable --- templates/test/variables.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/test/variables.tf b/templates/test/variables.tf index 72ebfcb4..0d30d9b6 100644 --- a/templates/test/variables.tf +++ b/templates/test/variables.tf @@ -28,5 +28,5 @@ variable "child_management_group_display_name" { variable "starter_locations" { type = list(string) description = "This is the fourth test variable|azure_location" - default = "uksouth" + default = ["uksouth"] } From ad7a55540f6a8326c2d8d5f8f1e14904e1ea8b92 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Mon, 30 Sep 2024 20:18:01 +0100 Subject: [PATCH 3/5] Remove default location from test --- templates/test/variables.tf | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/test/variables.tf b/templates/test/variables.tf index 0d30d9b6..9a98b19d 100644 --- a/templates/test/variables.tf +++ b/templates/test/variables.tf @@ -28,5 +28,4 @@ variable "child_management_group_display_name" { variable "starter_locations" { type = list(string) description = "This is the fourth test variable|azure_location" - default = ["uksouth"] } From 521ee839c5809cd2990b54a8e13e7f5457042095 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Tue, 1 Oct 2024 18:23:16 +0100 Subject: [PATCH 4/5] linting --- templates/complete_vnext/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/complete_vnext/main.tf b/templates/complete_vnext/main.tf index 2676d01f..03d974b3 100644 --- a/templates/complete_vnext/main.tf +++ b/templates/complete_vnext/main.tf @@ -1 +1 @@ -#TODO.. \ No newline at end of file +#TODO.. From 810cc9cfa903f7e5290abf5dc9bb86209647f199 Mon Sep 17 00:00:00 2001 From: Jared Holgate Date: Tue, 1 Oct 2024 18:28:43 +0100 Subject: [PATCH 5/5] Fix linting --- templates/complete_vnext/data.tf | 6 +-- templates/complete_vnext/locals.tf | 74 +-------------------------- templates/complete_vnext/outputs.tf | 1 + templates/complete_vnext/terraform.tf | 31 +---------- templates/complete_vnext/variables.tf | 38 +------------- 5 files changed, 5 insertions(+), 145 deletions(-) diff --git a/templates/complete_vnext/data.tf b/templates/complete_vnext/data.tf index de42e1d3..16725678 100644 --- a/templates/complete_vnext/data.tf +++ b/templates/complete_vnext/data.tf @@ -1,5 +1 @@ -data "azurerm_client_config" "core" {} - -data "azurerm_management_group" "root" { - name = local.root_parent_management_group_id -} +#TODO... diff --git a/templates/complete_vnext/locals.tf b/templates/complete_vnext/locals.tf index 64b6b9b1..03d974b3 100644 --- a/templates/complete_vnext/locals.tf +++ b/templates/complete_vnext/locals.tf @@ -1,73 +1 @@ -locals { - starter_location = var.starter_locations[0] -} -locals { - config_file_extension = replace(lower(element(local.config_file_split, length(local.config_file_split) - 1)), local.const_yml, local.const_yaml) - config_file_name = var.configuration_file_path == "" ? "config.yaml" : basename(var.configuration_file_path) - config_file_split = split(".", local.config_file_name) - const_yaml = "yaml" - const_yml = "yml" -} -locals { - config = (local.config_file_extension == local.const_yaml || local.config_file_extension == local.const_yml ? - yamldecode(templatefile("${path.module}/${local.config_file_name}", local.config_template_file_variables)) : - jsondecode(templatefile("${path.module}/${local.config_file_name}", local.config_template_file_variables)) - ) - config_template_file_variables = { - default_location = local.starter_location - default_postfix = var.default_postfix - root_parent_management_group_id = var.root_parent_management_group_id == "" ? data.azurerm_client_config.core.tenant_id : var.root_parent_management_group_id - subscription_id_connectivity = var.subscription_id_connectivity - subscription_id_identity = var.subscription_id_identity - subscription_id_management = var.subscription_id_management - } -} -locals { - management_group_resource_id_format = "/providers/Microsoft.Management/managementGroups/%s" - management_groups = { for k, v in local.config.management_groups : k => { - id = v.id - display_name = try(v.display_name, v.id) - parent = v.parent - parent_resource_id = v.parent == local.root_parent_management_group_id ? data.azurerm_management_group.root.id : format(local.management_group_resource_id_format, local.config.management_groups[v.parent].id) - base_archetype = v.base_archetype - subscriptions = try(v.subscriptions, []) - is_root = v.parent == local.root_parent_management_group_id - } - } - management_groups_layer_1 = { for k, v in local.management_groups : k => v if v.is_root } - management_groups_layer_2 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_1), v.parent) } - management_groups_layer_3 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_2), v.parent) } - management_groups_layer_4 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_3), v.parent) } - management_groups_layer_5 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_4), v.parent) } - management_groups_layer_6 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_5), v.parent) } - management_groups_layer_7 = { for k, v in local.management_groups : k => v if contains(keys(local.management_groups_layer_6), v.parent) } - root_parent_management_group_id = local.config_template_file_variables.root_parent_management_group_id -} -locals { - log_analytics_workspace_id = module.management_resources.log_analytics_workspace.id - management = local.config.management -} -locals { - hub_virtual_networks = try(merge(local.config.connectivity.hubnetworking.hub_virtual_networks, {}), {}) - module_hubnetworking = { - hub_virtual_networks = { - for key, hub_virtual_network in local.hub_virtual_networks : key => { - for argument, value in hub_virtual_network : argument => value if argument != "virtual_network_gateway" - } - } - } - module_virtual_network_gateway = { - for key, hub_virtual_network in local.hub_virtual_networks : key => merge( - hub_virtual_network.virtual_network_gateway, - { - location = hub_virtual_network.location - virtual_network_id = module.hubnetworking[0].virtual_networks[key].id - - } - ) - if can(hub_virtual_network.virtual_network_gateway) - } -} -locals { - module_vwan = try(merge(local.config.connectivity.vwan, {}), {}) -} +#TODO.. diff --git a/templates/complete_vnext/outputs.tf b/templates/complete_vnext/outputs.tf index e69de29b..16725678 100644 --- a/templates/complete_vnext/outputs.tf +++ b/templates/complete_vnext/outputs.tf @@ -0,0 +1 @@ +#TODO... diff --git a/templates/complete_vnext/terraform.tf b/templates/complete_vnext/terraform.tf index 36ee05ce..16725678 100644 --- a/templates/complete_vnext/terraform.tf +++ b/templates/complete_vnext/terraform.tf @@ -1,30 +1 @@ -terraform { - required_version = "~> 1.6" - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "~> 3.107" - } - azapi = { - source = "Azure/azapi" - version = "~> 1.13" - } - } - # backend "azurerm" {} -} - -provider "azurerm" { - features {} -} - -provider "azurerm" { - alias = "management" - subscription_id = var.subscription_id_management - features {} -} - -provider "azurerm" { - alias = "connectivity" - subscription_id = var.subscription_id_connectivity - features {} -} +#TODO... diff --git a/templates/complete_vnext/variables.tf b/templates/complete_vnext/variables.tf index 318c2884..16725678 100644 --- a/templates/complete_vnext/variables.tf +++ b/templates/complete_vnext/variables.tf @@ -1,37 +1 @@ -variable "starter_locations" { - type = list(string) - description = "The location for Azure resources. (e.g 'uksouth')|azure_location" -} - -variable "subscription_id_connectivity" { - type = string - description = "The identifier of the Connectivity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" -} - -variable "subscription_id_identity" { - type = string - description = "The identifier of the Identity Subscription. (e.g '00000000-0000-0000-0000-000000000000')|azure_subscription_id" -} - -variable "subscription_id_management" { - type = string - description = "The identifier of the Management Subscription. (e.g 00000000-0000-0000-0000-000000000000)|azure_subscription_id" -} - -variable "configuration_file_path" { - type = string - default = "" - description = "The path of the configuration file|configuration_file_path" -} - -variable "default_postfix" { - type = string - default = "landing-zone" - description = "The default postfix for Azure resources. (e.g 'landing-zone')|azure_name" -} - -variable "root_parent_management_group_id" { - type = string - default = "" - description = "The identifier of the Tenant Root Management Group, if left blank will use the tenant id. (e.g '00000000-0000-0000-0000-000000000000')|azure_name" -} +#TODO...