diff --git a/mmv1/templates/terraform/constants/iam_workload_identity_pool.go.tmpl b/mmv1/templates/terraform/constants/iam_workload_identity_pool.go.tmpl index 7a0fbb128b03..565b5996ae75 100644 --- a/mmv1/templates/terraform/constants/iam_workload_identity_pool.go.tmpl +++ b/mmv1/templates/terraform/constants/iam_workload_identity_pool.go.tmpl @@ -9,9 +9,7 @@ func ValidateWorkloadIdentityPoolId(v interface{}, k string) (ws []string, error "%q (%q) can not start with \"gcp-\"", k, value)) } - if strings.HasSuffix(value, defaultWorkloadIdentityPoolIdSuffix) { - value = strings.TrimRight(value, defaultWorkloadIdentityPoolIdSuffix) - } + value = strings.TrimSuffix(value, defaultWorkloadIdentityPoolIdSuffix) if !regexp.MustCompile(workloadIdentityPoolIdRegexp).MatchString(value) { errors = append(errors, fmt.Errorf( diff --git a/mmv1/third_party/terraform/services/iambeta/resource_iam_workload_identity_pool_id_test.go b/mmv1/third_party/terraform/services/iambeta/resource_iam_workload_identity_pool_id_test.go index 4af09f36862f..e2a44e4e8613 100644 --- a/mmv1/third_party/terraform/services/iambeta/resource_iam_workload_identity_pool_id_test.go +++ b/mmv1/third_party/terraform/services/iambeta/resource_iam_workload_identity_pool_id_test.go @@ -17,6 +17,7 @@ func TestValidateIAMBetaWorkloadIdentityPoolId(t *testing.T) { {TestName: "long", Value: "12345678901234567890123456789012"}, {TestName: "has a hyphen", Value: "foo-bar"}, {TestName: "default pool format", Value: "foo-bar.svc.id.goog"}, + {TestName: "default pool format with base name ending in a suffix character", Value: "goods.svc.id.goog"}, // With errors {TestName: "empty", Value: "", ExpectError: true}, @@ -26,6 +27,7 @@ func TestValidateIAMBetaWorkloadIdentityPoolId(t *testing.T) { {TestName: "has an backslash", Value: "foo\bar", ExpectError: true}, {TestName: "too short", Value: "foo", ExpectError: true}, {TestName: "too long", Value: strings.Repeat("f", 33), ExpectError: true}, + {TestName: "too long with suffix", Value: strings.Repeat("a", 32) + "g.svc.id.goog", ExpectError: true}, } es := verify.TestStringValidationCases(x, iambeta.ValidateWorkloadIdentityPoolId)