@@ -142,6 +142,51 @@ func TestAccComputeForwardingRule_forwardingRuleVpcPscExampleUpdate(t *testing.T
142
142
})
143
143
}
144
144
145
+ func TestAccComputeForwardingRule_forwardingRulePscRecreate (t * testing.T ) {
146
+ t .Parallel ()
147
+
148
+ context := map [string ]interface {}{
149
+ "random_suffix" : acctest .RandString (t , 10 ),
150
+ }
151
+
152
+ acctest .VcrTest (t , resource.TestCase {
153
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
154
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
155
+ CheckDestroy : testAccCheckComputeForwardingRuleDestroyProducer (t ),
156
+ Steps : []resource.TestStep {
157
+ {
158
+ Config : testAccComputeForwardingRule_forwardingRulePscRecreate (context ),
159
+ },
160
+ {
161
+ ResourceName : "google_compute_forwarding_rule.default" ,
162
+ ImportState : true ,
163
+ ImportStateVerify : true ,
164
+ ImportStateVerifyIgnore : []string {"recreate_closed_psc" },
165
+ },
166
+ {
167
+ Config : testAccComputeForwardingRule_forwardingRulePscRecreate (context ),
168
+ },
169
+ {
170
+ ResourceName : "google_compute_forwarding_rule.default" ,
171
+ ImportState : true ,
172
+ ImportStateVerify : true ,
173
+ ExpectNonEmptyPlan : true ,
174
+ ImportStateVerifyIgnore : []string {"recreate_closed_psc" },
175
+ },
176
+ {
177
+ Config : testAccComputeForwardingRule_forwardingRulePscRecreate (context ),
178
+ },
179
+ {
180
+ ResourceName : "google_compute_forwarding_rule.default" ,
181
+ ImportState : true ,
182
+ ImportStateVerify : true ,
183
+ ExpectNonEmptyPlan : true ,
184
+ ImportStateVerifyIgnore : []string {"recreate_closed_psc" },
185
+ },
186
+ },
187
+ })
188
+ }
189
+
145
190
func TestAccComputeForwardingRule_forwardingRuleRegionalSteeringExampleUpdate (t * testing.T ) {
146
191
t .Parallel ()
147
192
@@ -330,6 +375,107 @@ resource "google_compute_address" "consumer_address" {
330
375
}
331
376
332
377
378
+ // Producer service attachment
379
+
380
+ resource "google_compute_network" "producer_net" {
381
+ name = "tf-test-producer-net%{random_suffix}"
382
+ auto_create_subnetworks = false
383
+ }
384
+
385
+ resource "google_compute_subnetwork" "producer_subnet" {
386
+ name = "tf-test-producer-net%{random_suffix}"
387
+ ip_cidr_range = "10.0.0.0/16"
388
+ region = "us-central1"
389
+ network = google_compute_network.producer_net.id
390
+ }
391
+
392
+ resource "google_compute_subnetwork" "psc_producer_subnet" {
393
+ name = "tf-test-producer-psc-net%{random_suffix}"
394
+ ip_cidr_range = "10.1.0.0/16"
395
+ region = "us-central1"
396
+
397
+ purpose = "PRIVATE_SERVICE_CONNECT"
398
+ network = google_compute_network.producer_net.id
399
+ }
400
+
401
+ resource "google_compute_service_attachment" "producer_service_attachment" {
402
+ name = "tf-test-producer-service%{random_suffix}"
403
+ region = "us-central1"
404
+ description = "A service attachment configured with Terraform"
405
+
406
+ enable_proxy_protocol = true
407
+ connection_preference = "ACCEPT_AUTOMATIC"
408
+ nat_subnets = [google_compute_subnetwork.psc_producer_subnet.name]
409
+ target_service = google_compute_forwarding_rule.producer_target_service.id
410
+ }
411
+
412
+ resource "google_compute_forwarding_rule" "producer_target_service" {
413
+ name = "tf-test-producer-forwarding-rule%{random_suffix}"
414
+ region = "us-central1"
415
+
416
+ load_balancing_scheme = "INTERNAL"
417
+ backend_service = google_compute_region_backend_service.producer_service_backend.id
418
+ all_ports = true
419
+ network = google_compute_network.producer_net.name
420
+ subnetwork = google_compute_subnetwork.producer_subnet.name
421
+ }
422
+
423
+ resource "google_compute_region_backend_service" "producer_service_backend" {
424
+ name = "tf-test-producer-service-backend%{random_suffix}"
425
+ region = "us-central1"
426
+
427
+ health_checks = [google_compute_health_check.producer_service_health_check.id]
428
+ }
429
+
430
+ resource "google_compute_health_check" "producer_service_health_check" {
431
+ name = "tf-test-producer-service-health-check%{random_suffix}"
432
+
433
+ check_interval_sec = 1
434
+ timeout_sec = 1
435
+ tcp_health_check {
436
+ port = "80"
437
+ }
438
+ }
439
+ ` , context )
440
+ }
441
+
442
+ func testAccComputeForwardingRule_forwardingRulePscRecreate (context map [string ]interface {}) string {
443
+
444
+ return acctest .Nprintf (`
445
+ // Forwarding rule for VPC private service connect
446
+ resource "google_compute_forwarding_rule" "default" {
447
+ name = "tf-test-psc-endpoint%{random_suffix}"
448
+ region = "us-central1"
449
+ load_balancing_scheme = ""
450
+ target = google_compute_service_attachment.producer_service_attachment.id
451
+ network = google_compute_network.consumer_net.name
452
+ ip_address = google_compute_address.consumer_address.id
453
+ allow_psc_global_access = true
454
+ recreate_closed_psc = true
455
+ }
456
+
457
+ // Consumer service endpoint
458
+
459
+ resource "google_compute_network" "consumer_net" {
460
+ name = "tf-test-consumer-net%{random_suffix}"
461
+ auto_create_subnetworks = false
462
+ }
463
+
464
+ resource "google_compute_subnetwork" "consumer_subnet" {
465
+ name = "tf-test-consumer-net%{random_suffix}"
466
+ ip_cidr_range = "10.0.0.0/16"
467
+ region = "us-central1"
468
+ network = google_compute_network.consumer_net.id
469
+ }
470
+
471
+ resource "google_compute_address" "consumer_address" {
472
+ name = "tf-test-website-ip%{random_suffix}-1"
473
+ region = "us-central1"
474
+ subnetwork = google_compute_subnetwork.consumer_subnet.id
475
+ address_type = "INTERNAL"
476
+ }
477
+
478
+
333
479
// Producer service attachment
334
480
335
481
resource "google_compute_network" "producer_net" {
0 commit comments