Skip to content

Commit 270ad86

Browse files
Update Cloud Run v2 tests to make service account with sweepable name (#9620) (#16778)
[upstream:0124464a2158773138682030d38e0a454c998238] Signed-off-by: Modular Magician <[email protected]>
1 parent b6532c0 commit 270ad86

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

.changelog/9620.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google/services/cloudrunv2/data_source_google_cloud_run_v2_job_test.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func TestAccDataSourceGoogleCloudRunV2Job_bindIAMPermission(t *testing.T) {
7777

7878
project := envvar.GetTestProjectFromEnv()
7979

80-
name := fmt.Sprintf("tf-test-cloud-run-v2-job-%d", acctest.RandInt(t))
80+
name := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
8181
location := "us-central1"
8282
id := fmt.Sprintf("projects/%s/locations/%s/jobs/%s", project, location, name)
8383

@@ -124,18 +124,16 @@ data "google_cloud_run_v2_job" "hello" {
124124
}
125125
126126
resource "google_service_account" "foo" {
127-
account_id = "foo-service-account"
128-
display_name = "foo-service-account"
127+
account_id = "%s"
128+
display_name = "Service account for google_cloud_run_v2_job data source acceptance test "
129129
}
130130
131-
resource "google_cloud_run_v2_job_iam_binding" "foo_run_invoker" {
131+
resource "google_cloud_run_v2_job_iam_member" "foo_run_invoker" {
132132
name = data.google_cloud_run_v2_job.hello.name
133133
location = data.google_cloud_run_v2_job.hello.location
134134
135135
role = "roles/run.invoker"
136-
members = [
137-
"serviceAccount:${google_service_account.foo.email}",
138-
]
136+
member = "serviceAccount:${google_service_account.foo.email}"
139137
}
140-
`, name, location)
138+
`, name, location, name)
141139
}

google/services/cloudrunv2/data_source_google_cloud_run_v2_service_test.go

+6-8
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestAccDataSourceGoogleCloudRunV2Service_bindIAMPermission(t *testing.T) {
7070

7171
project := envvar.GetTestProjectFromEnv()
7272

73-
name := fmt.Sprintf("tf-test-cloud-run-v2-service-%d", acctest.RandInt(t))
73+
name := fmt.Sprintf("tf-test-%s", acctest.RandString(t, 10))
7474
location := "us-central1"
7575
id := fmt.Sprintf("projects/%s/locations/%s/services/%s", project, location, name)
7676

@@ -110,18 +110,16 @@ data "google_cloud_run_v2_service" "hello" {
110110
}
111111
112112
resource "google_service_account" "foo" {
113-
account_id = "foo-service-account"
114-
display_name = "foo-service-account"
113+
account_id = "%s"
114+
display_name = "Service account for google_cloud_run_v2_service data source acceptance test "
115115
}
116116
117-
resource "google_cloud_run_v2_service_iam_binding" "foo_run_invoker" {
117+
resource "google_cloud_run_v2_service_iam_member" "foo_run_invoker" {
118118
name = data.google_cloud_run_v2_service.hello.name
119119
location = data.google_cloud_run_v2_service.hello.location
120120
121121
role = "roles/run.invoker"
122-
members = [
123-
"serviceAccount:${google_service_account.foo.email}",
124-
]
122+
member = "serviceAccount:${google_service_account.foo.email}"
125123
}
126-
`, name, location)
124+
`, name, location, name)
127125
}

0 commit comments

Comments
 (0)