Skip to content

Commit ad0f34c

Browse files
committed
incl. for_each
1 parent 1ecd8f5 commit ad0f34c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

03-talos.tf

+3-5
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ module "talos_worker_group" {
4949
resource "talos_machine_secrets" "this" {}
5050

5151
data "talos_machine_configuration" "controlplane" {
52-
count = var.controlplane_count
53-
52+
for_each = { for index in range(0, var.controlplane_count) : index => index }
53+
5454
cluster_name = var.cluster_name
5555
cluster_endpoint = "https://${module.elb_k8s_elb.elb_dns_name}"
5656
machine_type = "controlplane"
@@ -66,7 +66,7 @@ data "talos_machine_configuration" "controlplane" {
6666
machine = {
6767
kubelet = {
6868
extraArgs = {
69-
hostname-override = module.talos_control_plane_nodes[count.index].id
69+
hostname-override = module.talos_control_plane_nodes[each.key].id
7070
}
7171
}
7272
}
@@ -109,7 +109,6 @@ data "talos_machine_configuration" "worker_group" {
109109

110110
resource "talos_machine_configuration_apply" "controlplane" {
111111
count = var.controlplane_count
112-
113112
client_configuration = talos_machine_secrets.this.client_configuration
114113
machine_configuration_input = data.talos_machine_configuration.controlplane[count.index].machine_configuration
115114
endpoint = module.talos_control_plane_nodes[count.index].public_ip
@@ -136,7 +135,6 @@ resource "talos_machine_bootstrap" "this" {
136135
data "talos_client_configuration" "this" {
137136
cluster_name = var.cluster_name
138137
client_configuration = talos_machine_secrets.this.client_configuration
139-
endpoints = module.talos_control_plane_nodes.*.public_ip
140138
}
141139

142140
resource "local_file" "talosconfig" {

0 commit comments

Comments
 (0)