Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
nellyk committed Mar 4, 2024
1 parent ab7c134 commit deeee1c
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 54 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ Description: This is the full output for the resource.

## Modules

The following Modules are called:
The following modules are called:

### <a name="module_regions"></a> [regions](#module\_regions)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- BEGIN_TF_DOCS -->
# AKS cluster with region having availability zone
# AKS cluster with the region having availability zone

This deploys the module with a region that has availability zones.

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ provider "azurerm" {
features {}
}


## Section to provide a random Azure region for the resource group
# This allows us to randomize the region for the resource group.
module "regions" {
source = "Azure/regions/azurerm"
version = ">= 0.3.0"
}

# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- BEGIN_TF_DOCS -->
# AKS cluster with region having no availability zone
# AKS cluster with region having no availability zone

This deploys the module with a region that has no availability zones.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# AKS cluster with region having no availability zone
# AKS cluster without availability zones

This deploys the module with a region that has no availability zones.
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,6 @@ provider "azurerm" {
features {}
}


## Section to provide a random Azure region for the resource group
# This allows us to randomize the region for the resource group.
module "regions" {
source = "Azure/regions/azurerm"
version = ">= 0.3.0"
}

# This ensures we have unique CAF compliant names for our resources.
module "naming" {
source = "Azure/naming/azurerm"
Expand Down
12 changes: 11 additions & 1 deletion locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@ locals {
}
]
]) : "${assoc.pe_key}-${assoc.asg_key}" => assoc }
}
}


# check if zone is available and return the zone if it is available
locals {
# zones = try(formatlist("%s", module.regions.regions_by_name[var.location == null ? local.resource_group_location : var.location].zones[(tonumber(count.index) - 1)]), null)
# remove the count and use something else for index
zones = try(formatlist("%s", module.regions.regions_by_name[var.location == null ? local.resource_group_location : var.location].zones), null)

}

20 changes: 10 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ resource "azurerm_management_lock" "this" {
}

resource "azurerm_kubernetes_cluster_node_pool" "this" {
# set max nodepools created to 3
for_each = var.node_pools

# if the region has zone create a node pool per zone
# if the region does not have zone create a single node pool with the zone as null
count = var.node_pools != null ? length(var.node_pools) == 1 ? 3 : length(var.node_pools) : 0
kubernetes_cluster_id = azurerm_kubernetes_cluster.this.id
name = "userpool${each.key}"
vm_size = each.value.vm_size
name = count.index
vm_size = var.node_pools[count.index].vm_size
enable_auto_scaling = true
max_count = each.value.max_count
min_count = each.value.min_count
node_count = each.value.node_count
os_sku = each.value.os_sku
max_count = var.node_pools[count.index].max_count
min_count = var.node_pools[count.index].min_count
node_count = var.node_pools[count.index].node_count
os_sku = var.node_pools[count.index].os_sku
tags = var.tags
zones = try(formatlist("%s", module.regions.regions_by_name[var.location == null ? local.resource_group_location : var.location].zones[(tonumber(each.key) - 1)]), null)
zones = local.zones[count.index]
}
resource "azurerm_role_assignment" "this" {
for_each = var.role_assignments
Expand Down
23 changes: 0 additions & 23 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,32 +117,9 @@ variable "node_pools" {
node_count = 2
os_sku = "Ubuntu"
mode = "User"
},
"2" = {
vm_size = "Standard_D4d_v5"
enable_auto_scaling = true
max_count = 110
min_count = 2
node_count = 2
os_sku = "Ubuntu"
mode = "User"
},
"3" = {
vm_size = "Standard_D4d_v5"
enable_auto_scaling = true
max_count = 110
min_count = 2
node_count = 2
os_sku = "Ubuntu"
mode = "User"
}
}
description = "The node pools to create on the Kubernetes Cluster."

validation {
condition = var.node_pools != null && length((var.node_pools)) >= 3
error_message = "The minimum number of user node pools recommended to users to create is 3"
}
}

variable "private_endpoints" {
Expand Down

0 comments on commit deeee1c

Please sign in to comment.