From 270ad8618b279a6558e439a429f38da313d93ac1 Mon Sep 17 00:00:00 2001 From: The Magician Date: Mon, 11 Dec 2023 16:00:45 -0800 Subject: [PATCH] Update Cloud Run v2 tests to make service account with sweepable name (#9620) (#16778) [upstream:0124464a2158773138682030d38e0a454c998238] Signed-off-by: Modular Magician --- .changelog/9620.txt | 3 +++ .../data_source_google_cloud_run_v2_job_test.go | 14 ++++++-------- ...data_source_google_cloud_run_v2_service_test.go | 14 ++++++-------- 3 files changed, 15 insertions(+), 16 deletions(-) create mode 100644 .changelog/9620.txt diff --git a/.changelog/9620.txt b/.changelog/9620.txt new file mode 100644 index 00000000000..8ec013c0699 --- /dev/null +++ b/.changelog/9620.txt @@ -0,0 +1,3 @@ +```release-note:none + +``` diff --git a/google/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go b/google/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go index a0cbfb0fcea..7c3fe02a9de 100644 --- a/google/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go +++ b/google/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go @@ -77,7 +77,7 @@ func TestAccDataSourceGoogleCloudRunV2Job_bindIAMPermission(t *testing.T) { project := envvar.GetTestProjectFromEnv() - name := fmt.Sprintf("tf-test-cloud-run-v2-job-%d", acctest.RandInt(t)) + name := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) location := "us-central1" id := fmt.Sprintf("projects/%s/locations/%s/jobs/%s", project, location, name) @@ -124,18 +124,16 @@ data "google_cloud_run_v2_job" "hello" { } resource "google_service_account" "foo" { - account_id = "foo-service-account" - display_name = "foo-service-account" + account_id = "%s" + display_name = "Service account for google_cloud_run_v2_job data source acceptance test " } -resource "google_cloud_run_v2_job_iam_binding" "foo_run_invoker" { +resource "google_cloud_run_v2_job_iam_member" "foo_run_invoker" { name = data.google_cloud_run_v2_job.hello.name location = data.google_cloud_run_v2_job.hello.location role = "roles/run.invoker" - members = [ - "serviceAccount:${google_service_account.foo.email}", - ] + member = "serviceAccount:${google_service_account.foo.email}" } -`, name, location) +`, name, location, name) } diff --git a/google/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go b/google/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go index 652723c9056..52c0cbe1901 100644 --- a/google/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go +++ b/google/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go @@ -70,7 +70,7 @@ func TestAccDataSourceGoogleCloudRunV2Service_bindIAMPermission(t *testing.T) { project := envvar.GetTestProjectFromEnv() - name := fmt.Sprintf("tf-test-cloud-run-v2-service-%d", acctest.RandInt(t)) + name := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10)) location := "us-central1" id := fmt.Sprintf("projects/%s/locations/%s/services/%s", project, location, name) @@ -110,18 +110,16 @@ data "google_cloud_run_v2_service" "hello" { } resource "google_service_account" "foo" { - account_id = "foo-service-account" - display_name = "foo-service-account" + account_id = "%s" + display_name = "Service account for google_cloud_run_v2_service data source acceptance test " } -resource "google_cloud_run_v2_service_iam_binding" "foo_run_invoker" { +resource "google_cloud_run_v2_service_iam_member" "foo_run_invoker" { name = data.google_cloud_run_v2_service.hello.name location = data.google_cloud_run_v2_service.hello.location role = "roles/run.invoker" - members = [ - "serviceAccount:${google_service_account.foo.email}", - ] + member = "serviceAccount:${google_service_account.foo.email}" } -`, name, location) +`, name, location, name) }