|
| 1 | +package google |
| 2 | + |
| 3 | +import ( |
| 4 | + "testing" |
| 5 | + |
| 6 | + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" |
| 7 | +) |
| 8 | + |
| 9 | +func TestAccVPCAccessConnector_vpcAccessConnectorThroughput(t *testing.T) { |
| 10 | + t.Parallel() |
| 11 | + |
| 12 | + context := map[string]interface{}{ |
| 13 | + "random_suffix": randString(t, 10), |
| 14 | + } |
| 15 | + |
| 16 | + vcrTest(t, resource.TestCase{ |
| 17 | + PreCheck: func() { testAccPreCheck(t) }, |
| 18 | + Providers: testAccProvidersOiCS, |
| 19 | + CheckDestroy: testAccCheckVPCAccessConnectorDestroyProducer(t), |
| 20 | + Steps: []resource.TestStep{ |
| 21 | + { |
| 22 | + Config: testAccVPCAccessConnector_vpcAccessConnectorThroughput(context), |
| 23 | + }, |
| 24 | + { |
| 25 | + ResourceName: "google_vpc_access_connector.connector", |
| 26 | + ImportState: true, |
| 27 | + ImportStateVerify: true, |
| 28 | + }, |
| 29 | + }, |
| 30 | + }) |
| 31 | +} |
| 32 | + |
| 33 | +func testAccVPCAccessConnector_vpcAccessConnectorThroughput(context map[string]interface{}) string { |
| 34 | + return Nprintf(` |
| 35 | +resource "google_vpc_access_connector" "connector" { |
| 36 | + provider = google-beta |
| 37 | + name = "tf-test-vpc-con%{random_suffix}" |
| 38 | + subnet { |
| 39 | + name = google_compute_subnetwork.custom_test.name |
| 40 | + } |
| 41 | + machine_type = "e2-standard-4" |
| 42 | + min_instances = 2 |
| 43 | + max_instances = 3 |
| 44 | + region = "us-central1" |
| 45 | +} |
| 46 | +
|
| 47 | +resource "google_compute_subnetwork" "custom_test" { |
| 48 | + provider = google-beta |
| 49 | + name = "tf-test-vpc-con%{random_suffix}" |
| 50 | + ip_cidr_range = "10.2.0.0/28" |
| 51 | + region = "us-central1" |
| 52 | + network = google_compute_network.custom_test.id |
| 53 | +} |
| 54 | +
|
| 55 | +resource "google_compute_network" "custom_test" { |
| 56 | + provider = google-beta |
| 57 | + name = "tf-test-vpc-con%{random_suffix}" |
| 58 | + auto_create_subnetworks = false |
| 59 | +} |
| 60 | +`, context) |
| 61 | +} |
0 commit comments