Skip to content

Commit 6563c3a

Browse files
committed
Fix issues with substr
* module.gke.google_service_account.cluster_service_account: substr: 'offset + length' cannot be larger than the length of the string in: tf-gke-${substr(var.name, 0, 20)}
1 parent 8205618 commit 6563c3a

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)