forked from roeldev/iac-talos-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtalos-output.tf
59 lines (49 loc) · 1.5 KB
/
talos-output.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
data "talos_cluster_kubeconfig" "this" {
depends_on = [talos_machine_bootstrap.this]
client_configuration = data.talos_client_configuration.this.client_configuration
node = cidrhost(var.network_cidr, var.control_plane_first_ip)
}
resource "local_sensitive_file" "export_talosconfig" {
depends_on = [data.talos_client_configuration.this]
content = data.talos_client_configuration.this.talos_config
filename = "${path.module}/output/talosconfig"
}
resource "local_sensitive_file" "export_kubeconfig" {
depends_on = [data.talos_cluster_kubeconfig.this]
content = data.talos_cluster_kubeconfig.this.kubeconfig_raw
filename = "${path.module}/output/kubeconfig"
}
data "external" "copy_talosconfig" {
depends_on = [local_sensitive_file.export_talosconfig]
program = [
"go",
"run",
"${path.module}/cmd/cp-to-home",
"${path.module}/output/talosconfig",
"~/.talos/config",
]
}
data "external" "copy_kubeconfig" {
depends_on = [local_sensitive_file.export_kubeconfig]
program = [
"go",
"run",
"${path.module}/cmd/cp-to-home",
"${path.module}/output/kubeconfig",
"~/.kube/config",
]
}
resource "null_resource" "talos-cluster-up" {
depends_on = [
data.external.copy_talosconfig,
data.external.copy_kubeconfig,
]
}
output "talos_client_configuration" {
value = data.talos_client_configuration.this
sensitive = true
}
output "talos_cluster_kubeconfig" {
value = data.talos_cluster_kubeconfig.this
sensitive = true
}