Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: reduce complexity #38

Merged
merged 1 commit into from
Mar 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions examples/terraform/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ data "talos_machine_configuration" "controlplane" {
}

data "talos_machine_configuration" "worker_group" {
for_each = merge([for info in var.worker_groups : { for index in range(0, info.num_instances) : "${info.name}.${index}" => info }]...)
for_each = merge([for info in var.worker_groups : { "${info.name}" = info }]...)

cluster_name = var.cluster_name
cluster_endpoint = "https://${module.elb_k8s_elb.elb_dns_name}"
Expand Down Expand Up @@ -353,10 +353,19 @@ resource "talos_machine_configuration_apply" "controlplane" {
}

resource "talos_machine_configuration_apply" "worker_group" {
for_each = merge([for info in var.worker_groups : { for index in range(0, info.num_instances) : "${info.name}.${index}" => info }]...)
for_each = merge([
for info in var.worker_groups : {
for index in range(0, info.num_instances) :
"${info.name}.${index}" => {
name = info.name,
public_ip = module.talos_worker_group["${info.name}.${index}"].public_ip,
private_ip = module.talos_worker_group["${info.name}.${index}"].private_ip
}
}
]...)

client_configuration = talos_machine_secrets.this.client_configuration
machine_configuration_input = data.talos_machine_configuration.worker_group[each.key].machine_configuration
machine_configuration_input = data.talos_machine_configuration.worker_group[each.value.name].machine_configuration
endpoint = module.talos_worker_group[each.key].public_ip
node = module.talos_worker_group[each.key].private_ip
}
Expand Down Expand Up @@ -384,7 +393,11 @@ data "talos_cluster_kubeconfig" "this" {
}

data "talos_cluster_health" "this" {
depends_on = [data.talos_cluster_kubeconfig.this]
depends_on = [
talos_machine_configuration_apply.controlplane,
talos_machine_configuration_apply.worker_group,
data.talos_cluster_kubeconfig.this
]

client_configuration = talos_machine_secrets.this.client_configuration
endpoints = module.talos_control_plane_nodes.*.public_ip
Expand Down
Loading