From 4ca426fb209f12dbee30f96cdc1e156943e3f7f5 Mon Sep 17 00:00:00 2001 From: Marcin Kaciuba Date: Wed, 24 Jul 2024 13:53:31 +0300 Subject: [PATCH] feat: get rid of self reference for the node_configuration --- main.tf | 4 ++-- variables.tf | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/main.tf b/main.tf index 98a2b1e..0d2f072 100644 --- a/main.tf +++ b/main.tf @@ -31,7 +31,7 @@ resource "castai_node_configuration" "this" { resource "castai_node_configuration_default" "this" { cluster_id = castai_gke_cluster.castai_cluster.id - configuration_id = var.default_node_configuration + configuration_id = var.default_node_configuration_name != "" ? castai_node_configuration.this[var.default_node_configuration_name].id : var.default_node_configuration } resource "castai_node_template" "this" { @@ -40,7 +40,7 @@ resource "castai_node_template" "this" { cluster_id = castai_gke_cluster.castai_cluster.id name = try(each.value.name, each.key) - configuration_id = try(each.value.configuration_id, null) + configuration_id = try(each.value.configuration_name, null) != null ? castai_node_configuration.this[each.value.configuration_name].id : try(each.value.configuration_id, null) is_default = try(each.value.is_default, false) is_enabled = try(each.value.is_enabled, true) should_taint = try(each.value.should_taint, true) diff --git a/variables.tf b/variables.tf index f8bf03a..e11c17b 100644 --- a/variables.tf +++ b/variables.tf @@ -87,6 +87,13 @@ variable "node_configurations" { variable "default_node_configuration" { type = string description = "ID of the default node configuration" + default = "" +} + +variable "default_node_configuration_name" { + type = string + description = "Name of the default node configuration" + default = "" } variable "node_templates" {