Skip to content

Commit

Permalink
remove global_settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Justin-DynamicD committed Mar 26, 2022
1 parent fbecd7c commit 8f24096
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 28 deletions.
8 changes: 4 additions & 4 deletions agw.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion aks.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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" {
Expand Down
4 changes: 2 additions & 2 deletions identity.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
15 changes: 7 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
8 changes: 3 additions & 5 deletions test/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
22 changes: 15 additions & 7 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 8f24096

Please sign in to comment.