@@ -13,6 +13,78 @@ import (
1313 "github.com/hashicorp/terraform-provider-google/google/services/cloudrunv2"
1414)
1515
16+ func TestAccCloudRunV2WorkerPool_vpcAccess_basic(t *testing.T) {
17+ t.Parallel()
18+
19+ ctx := map[string]interface{}{
20+ "rs": acctest.RandString(t, 10),
21+ "region": "us-central1",
22+ }
23+
24+ acctest.VcrTest(t, resource.TestCase{
25+ PreCheck: func() { acctest.AccTestPreCheck(t) },
26+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
27+ CheckDestroy: testAccCheckCloudRunV2WorkerPoolDestroyProducer(t),
28+ Steps: []resource.TestStep{
29+ {
30+ Config: testAccCloudRunV2WorkerPool_vpcAccess_basicConfig(ctx),
31+ },
32+ {
33+ ResourceName: "google_cloud_run_v2_worker_pool.primary",
34+ ImportState: true,
35+ ImportStateVerify: true,
36+ ImportStateVerifyIgnore: []string{
37+ "name", "location", "annotations", "labels", "terraform_labels",
38+ "deletion_protection",
39+ },
40+ },
41+ },
42+ })
43+ }
44+
45+ func testAccCloudRunV2WorkerPool_vpcAccess_basicConfig(ctx map[string]interface{}) string {
46+ return fmt.Sprintf(`
47+ resource "google_compute_network" "primary" {
48+ name = "tf-crwp-vpc-%[1]s"
49+ auto_create_subnetworks = false
50+ }
51+
52+ resource "google_compute_subnetwork" "primary" {
53+ name = "tf-crwp-subnet-%[1]s"
54+ ip_cidr_range = "10.0.0.0/16"
55+ region = "%[2]s"
56+ network = google_compute_network.primary.id
57+ }
58+
59+ resource "google_vpc_access_connector" "primary" {
60+ name = "tf-crwp-conn-%[1]s"
61+ region = "%[2]s"
62+ network = google_compute_network.primary.name
63+ ip_cidr_range = "10.8.0.0/28"
64+
65+ # Exigência atual da API: definir capacidade explícita
66+ min_instances = 2
67+ max_instances = 3
68+ }
69+
70+ resource "google_cloud_run_v2_worker_pool" "primary" {
71+ name = "tf-crwp-%[1]s"
72+ location = "%[2]s"
73+ deletion_protection = false
74+ launch_stage = "BETA"
75+
76+ template {
77+ containers {
78+ image = "gcr.io/cloudrun/hello"
79+ }
80+ vpc_access {
81+ connector = google_vpc_access_connector.primary.id
82+ }
83+ }
84+ }
85+ `, ctx["rs"], ctx["region"])
86+ }
87+
1688func TestAccCloudRunV2Service_cloudrunv2ServiceFullUpdate(t *testing.T) {
1789 t.Parallel()
1890
0 commit comments