Skip to content

Commit de467d9

Browse files
authored
Merge pull request #91 from basisai/fix-substr
Fix issues with `substr` for Service Accounts
2 parents daea924 + 2ed068f commit de467d9

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

autogen/sa.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ locals {
2424
resource "google_service_account" "cluster_service_account" {
2525
count = "${var.service_account == "create" ? 1 : 0}"
2626
project = "${var.project_id}"
27-
account_id = "tf-gke-${substr(var.name, 0, 20)}"
27+
account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}"
2828
display_name = "Terraform-managed service account for cluster ${var.name}"
2929
}
3030

modules/private-cluster/sa.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ locals {
2424
resource "google_service_account" "cluster_service_account" {
2525
count = "${var.service_account == "create" ? 1 : 0}"
2626
project = "${var.project_id}"
27-
account_id = "tf-gke-${substr(var.name, 0, 20)}"
27+
account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}"
2828
display_name = "Terraform-managed service account for cluster ${var.name}"
2929
}
3030

sa.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ locals {
2424
resource "google_service_account" "cluster_service_account" {
2525
count = "${var.service_account == "create" ? 1 : 0}"
2626
project = "${var.project_id}"
27-
account_id = "tf-gke-${substr(var.name, 0, 20)}"
27+
account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}"
2828
display_name = "Terraform-managed service account for cluster ${var.name}"
2929
}
3030

0 commit comments

Comments
 (0)