Skip to content

Commit d597d4a

Browse files
authored
Merge pull request #111 from terraform-google-modules/adrienthebo/bugfix/service-account-suffix
Add suffix to cluster service account
2 parents 567c586 + 1c7fda7 commit d597d4a

File tree

17 files changed

+89
-4
lines changed

17 files changed

+89
-4
lines changed

autogen/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,3 +107,8 @@ output "node_pools_versions" {
107107
description = "List of node pools versions"
108108
value = "${local.cluster_node_pools_versions}"
109109
}
110+
111+
output "service_account" {
112+
description = "The service account to default running nodes as if not overridden in `node_pools`."
113+
value = "${local.service_account}"
114+
}

autogen/sa.tf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@ locals {
2121
service_account = "${var.service_account == "create" ? element(local.service_account_list, 0) : var.service_account}"
2222
}
2323

24+
resource "random_string" "cluster_service_account_suffix" {
25+
upper = "false"
26+
lower = "true"
27+
special = "false"
28+
length = 4
29+
}
30+
2431
resource "google_service_account" "cluster_service_account" {
2532
count = "${var.service_account == "create" ? 1 : 0}"
2633
project = "${var.project_id}"
27-
account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}"
34+
account_id = "tf-gke-${substr(var.name, 0, min(15, length(var.name)))}-${random_string.cluster_service_account_suffix.result}"
2835
display_name = "Terraform-managed service account for cluster ${var.name}"
2936
}
3037

examples/deploy_service/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

examples/node_pool/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

examples/shared_vpc/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

examples/simple_regional/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

examples/simple_regional_private/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

examples/simple_zonal/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

examples/simple_zonal_private/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

examples/stub_domains/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,8 @@ output "client_token" {
2727
output "ca_certificate" {
2828
value = "${module.gke.ca_certificate}"
2929
}
30+
31+
output "service_account" {
32+
description = "The service account to default running nodes as if not overridden in `node_pools`."
33+
value = "${module.gke.service_account}"
34+
}

0 commit comments

Comments
 (0)