diff --git a/agw.tf b/agw.tf index d29d313..10717bf 100644 --- a/agw.tf +++ b/agw.tf @@ -2,8 +2,8 @@ resource "azurerm_public_ip" "main" { count = (local.app_gateway.enabled && local.app_gateway.public_ip_id == "") ? 1 : 0 name = local.names.agw - resource_group_name = local.global_settings.resource_group_name - location = local.global_settings.location + resource_group_name = local.resource_group_name + location = local.location allocation_method = "Static" sku = "Standard" zones = local.zones != [] ? local.zones : null @@ -30,8 +30,8 @@ resource "azurerm_application_gateway" "main" { count = local.app_gateway.enabled ? 1 : 0 name = local.names.agw - resource_group_name = local.global_settings.resource_group_name - location = local.global_settings.location + resource_group_name = local.resource_group_name + location = local.location zones = local.zones != [] ? local.zones : null sku { name = local.app_gateway.sku_name diff --git a/aks.tf b/aks.tf index 9bfc391..50e6b1f 100644 --- a/aks.tf +++ b/aks.tf @@ -28,7 +28,7 @@ resource "azurerm_kubernetes_cluster" "main" { ] } name = local.names.aks - location = local.global_settings.location + location = local.location dns_prefix = replace(local.names.aks, "-", "") resource_group_name = data.azurerm_resource_group.source.name sku_tier = local.aks.sku_tier diff --git a/data.tf b/data.tf index 36ef90b..223819d 100644 --- a/data.tf +++ b/data.tf @@ -8,7 +8,7 @@ # data "azurerm_client_config" "current" {} data "azurerm_resource_group" "source" { - name = local.global_settings.resource_group_name + name = local.resource_group_name } data "azurerm_container_registry" "list" { diff --git a/identity.tf b/identity.tf index 916c095..381148e 100644 --- a/identity.tf +++ b/identity.tf @@ -3,8 +3,8 @@ # and DNS updating resource "azurerm_user_assigned_identity" "main" { - resource_group_name = local.global_settings.resource_group_name - location = local.global_settings.location + resource_group_name = local.resource_group_name + location = local.location name = local.names.aks tags = local.tags } diff --git a/main.tf b/main.tf index 5a5fd3d..340ea48 100644 --- a/main.tf +++ b/main.tf @@ -26,9 +26,6 @@ locals { sku_tier = "WAF_v2" subnet_id = "" }) - global_settings = defaults(var.global_settings, { - name_prefix = "aks-baseline" - }) node_user_pool = defaults(var.node_user_pool, { enabled = true enable_auto_scaling = true @@ -52,12 +49,14 @@ locals { # generate the resource names for everything based on the values offered names = { - aks = coalesce(local.aks.name, "${local.global_settings.name_prefix}-aks") - agw = coalesce(local.app_gateway.name, "${local.global_settings.name_prefix}-agw") + aks = coalesce(local.aks.name, "${var.name_prefix}-aks") + agw = coalesce(local.app_gateway.name, "${var.name_prefix}-agw") } # these are unmodified, just dropped into locals for cconsistency - acr_list = var.acr_list - tags = var.tags - zones = var.zones + acr_list = var.acr_list + location = var.location + resource_group_name = var.resource_group_name + tags = var.tags + zones = var.zones } diff --git a/test/main.tf b/test/main.tf index b0407fc..f4c545f 100644 --- a/test/main.tf +++ b/test/main.tf @@ -41,11 +41,9 @@ module "aks" { depends_on = [ azurerm_resource_group.test ] - global_settings = { - location = azurerm_resource_group.test.location - name_prefix = "testaks" - resource_group_name = azurerm_resource_group.test.name - } + location = azurerm_resource_group.test.location + name_prefix = "testaks" + resource_group_name = azurerm_resource_group.test.name aks = { subnet_id = module.myvnet.vnet_subnets["aks_nodes"].id } diff --git a/variables.tf b/variables.tf index 52263c3..b6dd02c 100644 --- a/variables.tf +++ b/variables.tf @@ -2,13 +2,21 @@ # global variables ###### -variable global_settings { - type = object ({ - location = string - name_prefix = optional(string) - resource_group_name = string - }) - description = "collection of global variables common to every resource" +variable location { + type = string + description = "region to build all resources in" +} + +variable name_prefix { + type = string + description = "the prefix used in any generated resource name, if no overriding name is specified" + nullable = false + default = "aks-baseline" +} + +variable resource_group_name { + type = string + description = "name of the resource group to provision in" } variable app_gateway {