From 6563c3ad9f7079f40e5602694285b6017dfb9af3 Mon Sep 17 00:00:00 2001 From: Yong Wen Chua Date: Wed, 6 Mar 2019 12:14:49 +0800 Subject: [PATCH] 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)} --- autogen/sa.tf | 2 +- modules/private-cluster/sa.tf | 2 +- sa.tf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autogen/sa.tf b/autogen/sa.tf index 89c55f2e66..443f408601 100644 --- a/autogen/sa.tf +++ b/autogen/sa.tf @@ -24,7 +24,7 @@ locals { resource "google_service_account" "cluster_service_account" { count = "${var.service_account == "create" ? 1 : 0}" project = "${var.project_id}" - account_id = "tf-gke-${substr(var.name, 0, 20)}" + account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}" display_name = "Terraform-managed service account for cluster ${var.name}" } diff --git a/modules/private-cluster/sa.tf b/modules/private-cluster/sa.tf index 7ac956eef8..f766f0475d 100644 --- a/modules/private-cluster/sa.tf +++ b/modules/private-cluster/sa.tf @@ -24,7 +24,7 @@ locals { resource "google_service_account" "cluster_service_account" { count = "${var.service_account == "create" ? 1 : 0}" project = "${var.project_id}" - account_id = "tf-gke-${substr(var.name, 0, 20)}" + account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}" display_name = "Terraform-managed service account for cluster ${var.name}" } diff --git a/sa.tf b/sa.tf index 7ac956eef8..f766f0475d 100644 --- a/sa.tf +++ b/sa.tf @@ -24,7 +24,7 @@ locals { resource "google_service_account" "cluster_service_account" { count = "${var.service_account == "create" ? 1 : 0}" project = "${var.project_id}" - account_id = "tf-gke-${substr(var.name, 0, 20)}" + account_id = "tf-gke-${substr(var.name, 0, min(20, length(var.name)))}" display_name = "Terraform-managed service account for cluster ${var.name}" }