diff --git a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb index 560c34bf20a2..46023097e987 100644 --- a/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_container_cluster_test.go.erb @@ -4447,7 +4447,7 @@ func TestAccContainerCluster_failedCreation(t *testing.T) { clusterName := fmt.Sprintf("tf-test-cluster-%s", RandString(t, 10)) - project := BootstrapProject(t, "tf-fail-cluster-test", GetTestBillingAccountFromEnv(t), []string{"container.googleapis.com"}) + project := BootstrapProject(t, "tf-fail-cluster-", GetTestBillingAccountFromEnv(t), []string{"container.googleapis.com"}) removeContainerServiceAgentRoleFromContainerEngineRobot(t, project) VcrTest(t, resource.TestCase{ diff --git a/mmv1/third_party/terraform/utils/bootstrap_utils_test.go b/mmv1/third_party/terraform/utils/bootstrap_utils_test.go index bcb464bb4d36..b1b0700dc8c6 100644 --- a/mmv1/third_party/terraform/utils/bootstrap_utils_test.go +++ b/mmv1/third_party/terraform/utils/bootstrap_utils_test.go @@ -418,12 +418,21 @@ func removeContainerServiceAgentRoleFromContainerEngineRobot(t *testing.T, proje } } -func BootstrapProject(t *testing.T, projectID, billingAccount string, services []string) *cloudresourcemanager.Project { +// BootstrapProject will create or get a project named +// "" that will persist across test runs, +// where projectIDSuffix is based off of getTestProjectFromEnv(). The reason +// for the naming is to isolate bootstrapped projects by test environment. +// Given the existing projects being used by our team, the prefix provided to +// this function can be no longer than 18 characters. +func BootstrapProject(t *testing.T, projectIDPrefix, billingAccount string, services []string) *cloudresourcemanager.Project { config := BootstrapConfig(t) if config == nil { return nil } + projectIDSuffix := strings.Replace(GetTestProjectFromEnv(), "ci-test-project-", "", 1) + projectID := projectIDPrefix + projectIDSuffix + crmClient := config.NewResourceManagerClient(config.UserAgent) project, err := crmClient.Projects.Get(projectID).Do()