diff --git a/main.tf b/main.tf index 5cd3742..71119c8 100644 --- a/main.tf +++ b/main.tf @@ -50,7 +50,7 @@ resource "castai_node_configuration" "this" { resource "castai_node_configuration_default" "this" { cluster_id = castai_aks_cluster.castai_cluster.id - configuration_id = length(regexall(local.configuration_id_regex_pattern, var.default_node_configuration)) > 0 ? var.default_node_configuration : castai_node_configuration.this[var.default_node_configuration].id + configuration_id = var.default_node_configuration_name != "" ? castai_node_configuration.this[var.default_node_configuration_name].id : length(regexall(local.configuration_id_regex_pattern, var.default_node_configuration)) > 0 ? var.default_node_configuration : castai_node_configuration.this[var.default_node_configuration].id depends_on = [castai_node_configuration.this] } @@ -63,7 +63,7 @@ resource "castai_node_template" "this" { name = try(each.value.name, each.key) is_default = try(each.value.is_default, false) is_enabled = try(each.value.is_enabled, true) - configuration_id = can(each.value.configuration_id) ? length(regexall(local.configuration_id_regex_pattern, each.value.configuration_id)) > 0 ? each.value.configuration_id : castai_node_configuration.this[each.value.configuration_id].id : null + configuration_id = try(each.value.configuration_name, null) != null ? castai_node_configuration.this[each.value.configuration_name].id : can(each.value.configuration_id) ? length(regexall(local.configuration_id_regex_pattern, each.value.configuration_id)) > 0 ? each.value.configuration_id : castai_node_configuration.this[each.value.configuration_id].id : null should_taint = try(each.value.should_taint, true) rebalancing_config_min_nodes = try(each.value.rebalancing_config_min_nodes, 0) diff --git a/variables.tf b/variables.tf index c60c353..1813eee 100644 --- a/variables.tf +++ b/variables.tf @@ -104,6 +104,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" {