@@ -232,10 +232,11 @@ resource "google_compute_health_check" "default" {
232232` , context )
233233}
234234
235- func TestAccComputeGlobalForwardingRule_globalForwardingRulePrivateServicesConnectExample (t * testing.T ) {
235+ func TestAccComputeGlobalForwardingRule_privateServiceConnectGoogleApisExample (t * testing.T ) {
236236 t .Parallel ()
237237
238238 context := map [string ]interface {}{
239+ "project" : getTestProjectFromEnv (),
239240 "random_suffix" : randString (t , 10 ),
240241 }
241242
@@ -245,16 +246,34 @@ func TestAccComputeGlobalForwardingRule_globalForwardingRulePrivateServicesConne
245246 CheckDestroy : testAccCheckComputeGlobalForwardingRuleDestroyProducer (t ),
246247 Steps : []resource.TestStep {
247248 {
248- Config : testAccComputeGlobalForwardingRule_globalForwardingRulePrivateServicesConnectExample (context ),
249+ Config : testAccComputeGlobalForwardingRule_privateServiceConnectGoogleApisExample (context ),
249250 },
250251 },
251252 })
252253}
253254
254- func testAccComputeGlobalForwardingRule_globalForwardingRulePrivateServicesConnectExample (context map [string ]interface {}) string {
255+ func testAccComputeGlobalForwardingRule_privateServiceConnectGoogleApisExample (context map [string ]interface {}) string {
255256 return Nprintf (`
257+ resource "google_compute_network" "network" {
258+ provider = google-beta
259+ project = "%{project}"
260+ name = "tf-test-my-network%{random_suffix}"
261+ auto_create_subnetworks = false
262+ }
263+
264+ resource "google_compute_subnetwork" "vpc_subnetwork" {
265+ provider = google-beta
266+ project = google_compute_network.network.project
267+ name = "tf-test-my-subnetwork%{random_suffix}"
268+ ip_cidr_range = "10.2.0.0/16"
269+ region = "us-central1"
270+ network = google_compute_network.network.id
271+ private_ip_google_access = true
272+ }
273+
256274resource "google_compute_global_address" "default" {
257275 provider = google-beta
276+ project = google_compute_network.network.project
258277 name = "tf-test-global-psconnect-ip%{random_suffix}"
259278 address_type = "INTERNAL"
260279 purpose = "PRIVATE_SERVICE_CONNECT"
@@ -264,18 +283,13 @@ resource "google_compute_global_address" "default" {
264283
265284resource "google_compute_global_forwarding_rule" "default" {
266285 provider = google-beta
286+ project = google_compute_network.network.project
267287 name = "globalrule%{random_suffix}"
268288 target = "all-apis"
269289 network = google_compute_network.network.id
270290 ip_address = google_compute_global_address.default.id
271291 load_balancing_scheme = ""
272292}
273-
274- resource "google_compute_network" "network" {
275- provider = google-beta
276- name = "tf-test%{random_suffix}"
277- auto_create_subnetworks = false
278- }
279293` , context )
280294}
281295
0 commit comments