@@ -357,6 +357,66 @@ func TestAccComputeRouterNat_withNatRules(t *testing.T) {
357
357
})
358
358
}
359
359
360
+ func TestAccComputeRouterNat_withEndpointTypes (t * testing.T ) {
361
+ t .Parallel ()
362
+
363
+ testId := acctest .RandString (t , 10 )
364
+ routerName := fmt .Sprintf ("tf-test-router-nat-%s" , testId )
365
+ testResourceName := "google_compute_router_nat.foobar"
366
+
367
+ acctest .VcrTest (t , resource.TestCase {
368
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
369
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
370
+ CheckDestroy : testAccCheckComputeRouterNatDestroyProducer (t ),
371
+ Steps : []resource.TestStep {
372
+ {
373
+ Config : testAccComputeRouterNatBasic (routerName ),
374
+ Check : resource .ComposeTestCheckFunc (
375
+ resource .TestCheckResourceAttr (testResourceName , "endpoint_types.0" , "ENDPOINT_TYPE_VM" ),
376
+ ),
377
+ },
378
+ {
379
+ ResourceName : testResourceName ,
380
+ ImportState : true ,
381
+ ImportStateVerify : true ,
382
+ },
383
+ {
384
+ Config : testAccComputeRouterNatUpdateEndpointType (routerName , "ENDPOINT_TYPE_SWG" ),
385
+ Check : resource .ComposeTestCheckFunc (
386
+ resource .TestCheckResourceAttr (testResourceName , "endpoint_types.0" , "ENDPOINT_TYPE_SWG" ),
387
+ ),
388
+ },
389
+ {
390
+ ResourceName : testResourceName ,
391
+ ImportState : true ,
392
+ ImportStateVerify : true ,
393
+ },
394
+ {
395
+ Config : testAccComputeRouterNatUpdateEndpointType (routerName , "ENDPOINT_TYPE_VM" ),
396
+ Check : resource .ComposeTestCheckFunc (
397
+ resource .TestCheckResourceAttr (testResourceName , "endpoint_types.0" , "ENDPOINT_TYPE_VM" ),
398
+ ),
399
+ },
400
+ {
401
+ ResourceName : testResourceName ,
402
+ ImportState : true ,
403
+ ImportStateVerify : true ,
404
+ },
405
+ {
406
+ Config : testAccComputeRouterNatUpdateEndpointType (routerName , "ENDPOINT_TYPE_MANAGED_PROXY_LB" ),
407
+ Check : resource .ComposeTestCheckFunc (
408
+ resource .TestCheckResourceAttr (testResourceName , "endpoint_types.0" , "ENDPOINT_TYPE_MANAGED_PROXY_LB" ),
409
+ ),
410
+ },
411
+ {
412
+ ResourceName : testResourceName ,
413
+ ImportState : true ,
414
+ ImportStateVerify : true ,
415
+ },
416
+ },
417
+ })
418
+ }
419
+
360
420
func testAccCheckComputeRouterNatDestroyProducer (t * testing.T ) func (s * terraform.State ) error {
361
421
return func (s * terraform.State ) error {
362
422
config := acctest .GoogleProviderConfig (t )
@@ -559,6 +619,40 @@ resource "google_compute_router_nat" "foobar" {
559
619
` , routerName , routerName , routerName , routerName , routerName )
560
620
}
561
621
622
+ func testAccComputeRouterNatUpdateEndpointType (routerName string , endpointType string ) string {
623
+ return fmt .Sprintf (`
624
+ resource "google_compute_network" "foobar" {
625
+ name = "%[1]s-net"
626
+ }
627
+
628
+ resource "google_compute_subnetwork" "foobar" {
629
+ name = "%[1]s-subnet"
630
+ network = google_compute_network.foobar.self_link
631
+ ip_cidr_range = "10.0.0.0/16"
632
+ region = "us-central1"
633
+ }
634
+
635
+ resource "google_compute_router" "foobar" {
636
+ name = "%[1]s"
637
+ region = google_compute_subnetwork.foobar.region
638
+ network = google_compute_network.foobar.self_link
639
+ }
640
+
641
+ resource "google_compute_router_nat" "foobar" {
642
+ name = "%[1]s"
643
+ router = google_compute_router.foobar.name
644
+ region = google_compute_router.foobar.region
645
+ nat_ip_allocate_option = "AUTO_ONLY"
646
+ source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
647
+ endpoint_types = [ "%[2]s" ]
648
+ log_config {
649
+ enable = true
650
+ filter = "ERRORS_ONLY"
651
+ }
652
+ }
653
+ ` , routerName , endpointType )
654
+ }
655
+
562
656
func testAccComputeRouterNatUpdateToNatIPsId (routerName string ) string {
563
657
return fmt .Sprintf (`
564
658
resource "google_compute_router" "foobar" {
0 commit comments