From 9c30524b34fd66b556b4154afcc6df68f782066f Mon Sep 17 00:00:00 2001 From: Marcel Richter Date: Fri, 11 Oct 2024 21:51:35 +0200 Subject: [PATCH] fix(talos): change `talos_cluster_kubeconfig` to resource Closes: https://github.com/hcloud-talos/terraform-hcloud-talos/issues/89 --- talos.tf | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/talos.tf b/talos.tf index 481a64d..d1c7b1d 100644 --- a/talos.tf +++ b/talos.tf @@ -119,7 +119,7 @@ data "talos_client_configuration" "this" { ) } -data "talos_cluster_kubeconfig" "this" { +resource "talos_cluster_kubeconfig" "this" { count = var.control_plane_count > 0 ? 1 : 0 client_configuration = talos_machine_secrets.this.client_configuration node = local.control_plane_public_ipv4_list[0] @@ -136,15 +136,15 @@ locals { "unknown" ) kubeconfig = replace( - can(data.talos_cluster_kubeconfig.this[0].kubeconfig_raw) ? data.talos_cluster_kubeconfig.this[0].kubeconfig_raw : "", + can(talos_cluster_kubeconfig.this[0].kubeconfig_raw) ? talos_cluster_kubeconfig.this[0].kubeconfig_raw : "", local.cluster_endpoint_url_internal, "https://${local.kubeconfig_host}:${local.api_port_k8s}" ) kubeconfig_data = { host = "https://${local.best_public_ipv4}:${local.api_port_k8s}" cluster_name = var.cluster_name - cluster_ca_certificate = var.control_plane_count > 0 ? base64decode(data.talos_cluster_kubeconfig.this[0].kubernetes_client_configuration.ca_certificate) : tls_self_signed_cert.dummy_ca[0].cert_pem - client_certificate = var.control_plane_count > 0 ? base64decode(data.talos_cluster_kubeconfig.this[0].kubernetes_client_configuration.client_certificate) : tls_locally_signed_cert.dummy_issuer[0].cert_pem - client_key = var.control_plane_count > 0 ? base64decode(data.talos_cluster_kubeconfig.this[0].kubernetes_client_configuration.client_key) : tls_private_key.dummy_issuer[0].private_key_pem + cluster_ca_certificate = var.control_plane_count > 0 ? base64decode(talos_cluster_kubeconfig.this[0].kubernetes_client_configuration.ca_certificate) : tls_self_signed_cert.dummy_ca[0].cert_pem + client_certificate = var.control_plane_count > 0 ? base64decode(talos_cluster_kubeconfig.this[0].kubernetes_client_configuration.client_certificate) : tls_locally_signed_cert.dummy_issuer[0].cert_pem + client_key = var.control_plane_count > 0 ? base64decode(talos_cluster_kubeconfig.this[0].kubernetes_client_configuration.client_key) : tls_private_key.dummy_issuer[0].private_key_pem } }