From 385bd788be27833c27275b3477add5d3f271c312 Mon Sep 17 00:00:00 2001 From: Karim Naufal Date: Fri, 4 Mar 2022 23:41:49 +0100 Subject: [PATCH] reduced number of words in names and remove cluster name in node names --- agents.tf | 3 ++- control_planes.tf | 5 +++-- locals.tf | 1 + main.tf | 1 + output.tf | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/agents.tf b/agents.tf index 0bdb214..b279e0e 100644 --- a/agents.tf +++ b/agents.tf @@ -1,5 +1,6 @@ resource "random_pet" "agents" { for_each = local.agent_nodepools + length = 1 } module "agents" { @@ -7,7 +8,7 @@ module "agents" { for_each = local.agent_nodepools - name = "${each.key}-${random_pet.cluster.id}-${random_pet.agents[each.key].id}" + name = "${each.value.nodepool_name}-${random_pet.agents[each.key].id}" ssh_keys = [hcloud_ssh_key.k3s.id] public_key = var.public_key private_key = var.private_key diff --git a/control_planes.tf b/control_planes.tf index 082319a..adccd05 100644 --- a/control_planes.tf +++ b/control_planes.tf @@ -1,12 +1,13 @@ resource "random_pet" "control_planes" { - count = var.control_plane_count + count = var.control_plane_count + length = 1 } module "control_planes" { source = "./modules/host" count = var.control_plane_count - name = "control-plane-${random_pet.cluster.id}-${random_pet.control_planes[count.index].id}" + name = "control-plane-${random_pet.control_planes[count.index].id}" ssh_keys = [hcloud_ssh_key.k3s.id] public_key = var.public_key diff --git a/locals.tf b/locals.tf index 595cf45..a01b5cd 100644 --- a/locals.tf +++ b/locals.tf @@ -173,6 +173,7 @@ locals { for nodepool_name, nodepool_obj in var.agent_nodepools : { for index in range(nodepool_obj.count) : format("%s-%s", nodepool_name, index) => { + nodepool_name : nodepool_name, server_type : nodepool_obj.server_type, subnet : nodepool_obj.subnet, index : index diff --git a/main.tf b/main.tf index 1ca3bf6..fa0da53 100644 --- a/main.tf +++ b/main.tf @@ -1,4 +1,5 @@ resource "random_pet" "cluster" { + length = 1 } resource "random_password" "k3s_token" { diff --git a/output.tf b/output.tf index aa0604c..6631e6d 100644 --- a/output.tf +++ b/output.tf @@ -1,5 +1,5 @@ output "cluster_pet_name" { - value = random_pet.cluster + value = random_pet.cluster.id description = "Shared suffix for all resources belonging to this cluster." }