Skip to content
This repository was archived by the owner on Aug 12, 2024. It is now read-only.

Commit 49ac771

Browse files
author
Sean Sundberg
authored
Updates handling of kube config (#12)
- Always run the create_dirs resource - Don't move the kubeconfig files, refer to them where they are created Signed-off-by: Sean Sundberg <[email protected]>
1 parent ac1e1e1 commit 49ac771

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

main-2-config.tf

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@ data ibm_container_cluster_config cluster {
6767
resource null_resource setup_kube_config {
6868
depends_on = [null_resource.create_dirs, data.ibm_container_cluster_config.cluster]
6969

70-
provisioner "local-exec" {
71-
command = "rm -f ${local.cluster_config} && ln -s ${data.ibm_container_cluster_config.cluster.config_file_path} ${local.cluster_config}"
72-
}
73-
74-
provisioner "local-exec" {
75-
command = "cp ${regex("(.*)/config.yml", data.ibm_container_cluster_config.cluster.config_file_path)[0]}/* ${local.cluster_config_dir}"
76-
}
77-
7870
provisioner "local-exec" {
7971
command = "echo 'Waiting for 5 minutes for permissions to be established...' && sleep 300"
8072
}

main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ locals {
1818
}
1919
}
2020
cluster_config_dir = "${path.cwd}/.kube"
21-
cluster_config = "${local.cluster_config_dir}/config"
21+
cluster_config = data.ibm_container_cluster_config.cluster.config_file_path
2222
cluster_type_file = "${path.cwd}/.tmp/cluster_type.val"
2323
name_prefix = var.name_prefix != "" ? var.name_prefix : var.resource_group_name
2424
name_list = [local.name_prefix, "cluster"]
@@ -48,9 +48,14 @@ locals {
4848
}
4949

5050
resource null_resource create_dirs {
51+
triggers = {
52+
always_run = timestamp()
53+
}
54+
5155
provisioner "local-exec" {
5256
command = "echo 'regex: ${local.cluster_regex}'"
5357
}
58+
5459
provisioner "local-exec" {
5560
command = "echo 'cluster_type_cleaned: ${local.cluster_type_cleaned}'"
5661
}
@@ -76,6 +81,7 @@ resource null_resource print_resources {
7681
}
7782
}
7883

84+
# separated to prevent circular dependency
7985
resource null_resource print_subnets {
8086
provisioner "local-exec" {
8187
command = "echo 'VPC subnet count: ${local.vpc_subnet_count}'"

0 commit comments

Comments
 (0)