From 4369f0271b12cd3f98f705df036662f0660efa4b Mon Sep 17 00:00:00 2001 From: Joshua Spence Date: Mon, 21 Oct 2019 23:55:29 +1100 Subject: [PATCH] Allow `config_output_path` to specify the full path (#549) --- CHANGELOG.md | 3 ++- README.md | 4 ++-- kubectl.tf | 2 +- variables.tf | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cf41f9..046e855 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,8 @@ project adheres to [Semantic Versioning](http://semver.org/). ### Changed - - Changed logic for setting default ebs_optimized to only require maintaining a list of instance types that don't support it (by @jeffmhastings) +- **Breaking:** The `kubectl` configuration file can now be fully-specified using `config_output_path`. Previously it was assumed that `config_output_path` referred to a directory and always ended with a forward slash. This is a breaking change if `config_output_path` does **not** end with a forward slash (which was advised against by the documentation). +- Changed logic for setting default ebs_optimized to only require maintaining a list of instance types that don't support it (by @jeffmhastings) # History diff --git a/README.md b/README.md index 4f475d7..f2fc94c 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a | cluster\_name | Name of the EKS cluster. Also used as a prefix in names of related resources. | string | n/a | yes | | cluster\_security\_group\_id | If provided, the EKS cluster will be attached to this security group. If not given, a security group will be created with necessary ingres/egress to work with the workers | string | `""` | no | | cluster\_version | Kubernetes version to use for the EKS cluster. | string | `"1.14"` | no | -| config\_output\_path | Where to save the Kubectl config file (if `write_kubeconfig = true`). Should end in a forward slash `/` . | string | `"./"` | no | +| config\_output\_path | Where to save the Kubectl config file (if `write_kubeconfig = true`). Assumed to be a directory if the value ends with a forward slash `/`. | string | `"./"` | no | | iam\_path | If provided, all IAM roles will be created on this path. | string | `"/"` | no | | kubeconfig\_aws\_authenticator\_additional\_args | Any additional arguments to pass to the authenticator such as the role to assume. e.g. ["-r", "MyEksRole"]. | list(string) | `[]` | no | | kubeconfig\_aws\_authenticator\_command | Command to use to fetch AWS EKS credentials. | string | `"aws-iam-authenticator"` | no | @@ -188,4 +188,4 @@ MIT Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-a | workers\_launch\_template\_latest\_versions | Latest versions of the worker launch templates. | | workers\_user\_data | User data of worker groups | - \ No newline at end of file + diff --git a/kubectl.tf b/kubectl.tf index ede1575..5a70828 100644 --- a/kubectl.tf +++ b/kubectl.tf @@ -1,6 +1,6 @@ resource "local_file" "kubeconfig" { count = var.write_kubeconfig ? 1 : 0 content = data.template_file.kubeconfig.rendered - filename = "${var.config_output_path}kubeconfig_${var.cluster_name}" + filename = "${substr(var.config_output_path, -1, 1) == "/" ? "${var.config_output_path}kubeconfig_${var.cluster_name}" : var.config_output_path}" } diff --git a/variables.tf b/variables.tf index 9d3a479..a4d2d4d 100644 --- a/variables.tf +++ b/variables.tf @@ -32,7 +32,7 @@ variable "cluster_version" { } variable "config_output_path" { - description = "Where to save the Kubectl config file (if `write_kubeconfig = true`). Should end in a forward slash `/` ." + description = "Where to save the Kubectl config file (if `write_kubeconfig = true`). Assumed to be a directory if the value ends with a forward slash `/`." type = string default = "./" }