Skip to content

Commit

Permalink
separate name and terraform index key naming
Browse files Browse the repository at this point in the history
  • Loading branch information
aimee-889 committed Dec 18, 2023
1 parent 1dedf11 commit efdb351
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions modules/ionos-k8s-cluster/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ resource "ionoscloud_k8s_cluster" "cluster" {
#----

resource "ionoscloud_k8s_node_pool" "nodepool_scaling" {
for_each = {for np in local.nodepool_per_zone_creator : lower("${local.cluster_name}-${replace(np.availability_zone, "_", "")}-${length(np.purpose) > 0 ? "${np.purpose}-" : ""}nodepool-${np.nodepool_index}") => np if np.auto_scaling == true}
for_each = {for np in local.nodepool_per_zone_creator : "${np.availability_zone}-${np.purpose}-${np.nodepool_index}" => np if np.auto_scaling == true}
availability_zone = each.value.availability_zone
name = each.key
name = lower("${local.cluster_name}-${replace(each.value.availability_zone, "_", "")}-${length(each.value.purpose) > 0 ? "${each.value.purpose}-" : ""}nodepool-${each.value.nodepool_index}")
k8s_version = ionoscloud_k8s_cluster.cluster.k8s_version
allow_replace = each.value.allow_node_pool_replacement
# the lans are created as a dynamic block - they help to dynamically construct repeatable nested blocks
Expand Down Expand Up @@ -119,8 +119,7 @@ resource "ionoscloud_k8s_node_pool" "nodepool_legacy" {

resource "ionoscloud_ipblock" "ippools" {
for_each = {for np in local.nodepool_per_zone_creator : "${np.availability_zone}-${np.purpose}-${np.nodepool_index}" => np if np.create_public_ip_pools == true}
# for_each = {for np in local.nodepool_per_zone_creator : lower("${local.cluster_name}-${replace(np.availability_zone, "_", "")}-${length(np.purpose) > 0 ? "${np.purpose}-" : ""}nodepool-${np.nodepool_index}") => np if np.create_public_ip_pools == true}
name = each.key
name = lower("${local.cluster_name}-${replace(each.key, "_", "")}-nodepool")
location = var.datacenter_location
size = each.value.auto_scaling ? each.value.max_node_count + 1 : each.value.node_count + 1
}

0 comments on commit efdb351

Please sign in to comment.