Skip to content

Commit 55862a0

Browse files
committed
Support for disabling basic auth / client cert
* [Added] `enable_basic_auth` variable. defaults to `false`<sup>1</sup> * [Added] `basic_auth_username` variable. defaults to `""` * [Added] `basic_auth_password` variable. defaults to `""` * [Added] `issue_client_certificate` variable. defaults to `true`<sup>2</sup> Notes: 1. This will cause a plan change for existing users. Enabling it will require them to set a username and password. 2. This is enabled by default, despite being a poor security practice because changing this value is destructive to the cluster and we decided to err on not trigger *destroy* plan changes to existing users.
1 parent 3398b11 commit 55862a0

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

cluster_regional.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ resource "google_container_cluster" "primary" {
3535

3636
master_authorized_networks_config = "${var.master_authorized_networks_config}"
3737

38+
master_auth {
39+
username = "${local.cluster_basic_auth_username}"
40+
password = "${local.cluster_basic_auth_password}"
41+
42+
client_certificate_config {
43+
issue_client_certificate = "${var.issue_client_certificate}"
44+
}
45+
}
46+
3847
addons_config {
3948
http_load_balancing {
4049
disabled = "${var.http_load_balancing ? 0 : 1}"

cluster_zonal.tf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ resource "google_container_cluster" "zonal_primary" {
3535

3636
master_authorized_networks_config = "${var.master_authorized_networks_config}"
3737

38+
master_auth {
39+
username = "${local.cluster_basic_auth_username}"
40+
password = "${local.cluster_basic_auth_password}"
41+
42+
client_certificate_config {
43+
issue_client_certificate = "${var.issue_client_certificate}"
44+
}
45+
}
46+
3847
addons_config {
3948
http_load_balancing {
4049
disabled = "${var.http_load_balancing ? 0 : 1}"

main.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ locals {
140140
cluster_http_load_balancing_enabled = "${local.cluster_type_output_http_load_balancing_enabled[local.cluster_type] ? false : true}"
141141
cluster_horizontal_pod_autoscaling_enabled = "${local.cluster_type_output_horizontal_pod_autoscaling_enabled[local.cluster_type] ? false : true}"
142142
cluster_kubernetes_dashboard_enabled = "${local.cluster_type_output_kubernetes_dashboard_enabled[local.cluster_type] ? false : true}"
143+
144+
cluster_basic_auth_username = "${var.enable_basic_auth ? var.basic_auth_username : ""}"
145+
cluster_basic_auth_password = "${var.enable_basic_auth ? var.basic_auth_password : ""}"
143146
}
144147

145148
/******************************************

variables.tf

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,23 @@ variable "monitoring_service" {
189189
description = "The monitoring service that the cluster should write metrics to. Automatically send metrics from pods in the cluster to the Google Cloud Monitoring API. VM metrics will be collected by Google Compute Engine regardless of this setting Available options include monitoring.googleapis.com, monitoring.googleapis.com/kubernetes (beta) and none"
190190
default = "monitoring.googleapis.com"
191191
}
192+
193+
variable "enable_basic_auth" {
194+
description = "Basic authentication allows a user to authenticate to the cluster with a username and password. To maximize the security of your cluster, disable this option. Basic authentication is not recommended because it provides no confidentiality protection for transmitted credentials. Default: true"
195+
default = true
196+
}
197+
198+
variable "basic_auth_username" {
199+
description = "Kubernetes HTTP Basic auth username. Defaults to empty string. Only used if `enable_basic_auth` is true"
200+
default = ""
201+
}
202+
203+
variable "basic_auth_password" {
204+
description = "Kubernetes HTTP Basic auth password. Defaults to empty string. Only used if `enable_basic_auth` is true"
205+
default = ""
206+
}
207+
208+
variable "issue_client_certificate" {
209+
description = "Issues a client certificate to authenticate to the cluster endpoint. To maximize the security of your cluster, leave this option disabled. Client certificates don't automatically rotate and aren't easily revocable. WARNING: changing this after cluster creation is destructive! Default: false"
210+
default = false
211+
}

0 commit comments

Comments
 (0)