@@ -410,6 +410,66 @@ func TestAccComputeRouterNat_withNatRules(t *testing.T) {
410
410
})
411
411
}
412
412
413
+ func TestAccComputeRouterNat_withEndpointTypes(t *testing.T) {
414
+ t.Parallel()
415
+
416
+ testId := acctest.RandString(t, 10)
417
+ routerName := fmt.Sprintf("tf-test-router-nat-%s", testId)
418
+ testResourceName := "google_compute_router_nat.foobar"
419
+
420
+ acctest.VcrTest(t, resource.TestCase{
421
+ PreCheck: func() { acctest.AccTestPreCheck(t) },
422
+ ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
423
+ CheckDestroy: testAccCheckComputeRouterNatDestroyProducer(t),
424
+ Steps: []resource.TestStep{
425
+ {
426
+ Config: testAccComputeRouterNatBasic(routerName),
427
+ Check: resource.ComposeTestCheckFunc(
428
+ resource.TestCheckResourceAttr(testResourceName, "endpoint_types.0", "ENDPOINT_TYPE_VM"),
429
+ ),
430
+ },
431
+ {
432
+ ResourceName: testResourceName,
433
+ ImportState: true,
434
+ ImportStateVerify: true,
435
+ },
436
+ {
437
+ Config: testAccComputeRouterNatUpdateEndpointType(routerName, "ENDPOINT_TYPE_SWG"),
438
+ Check: resource.ComposeTestCheckFunc(
439
+ resource.TestCheckResourceAttr(testResourceName, "endpoint_types.0", "ENDPOINT_TYPE_SWG"),
440
+ ),
441
+ },
442
+ {
443
+ ResourceName: testResourceName,
444
+ ImportState: true,
445
+ ImportStateVerify: true,
446
+ },
447
+ {
448
+ Config: testAccComputeRouterNatUpdateEndpointType(routerName, "ENDPOINT_TYPE_VM"),
449
+ Check: resource.ComposeTestCheckFunc(
450
+ resource.TestCheckResourceAttr(testResourceName, "endpoint_types.0", "ENDPOINT_TYPE_VM"),
451
+ ),
452
+ },
453
+ {
454
+ ResourceName: testResourceName,
455
+ ImportState: true,
456
+ ImportStateVerify: true,
457
+ },
458
+ {
459
+ Config: testAccComputeRouterNatUpdateEndpointType(routerName, "ENDPOINT_TYPE_MANAGED_PROXY_LB"),
460
+ Check: resource.ComposeTestCheckFunc(
461
+ resource.TestCheckResourceAttr(testResourceName, "endpoint_types.0", "ENDPOINT_TYPE_MANAGED_PROXY_LB"),
462
+ ),
463
+ },
464
+ {
465
+ ResourceName: testResourceName,
466
+ ImportState: true,
467
+ ImportStateVerify: true,
468
+ },
469
+ },
470
+ })
471
+ }
472
+
413
473
<% unless version == 'ga' -%>
414
474
func TestAccComputeRouterNat_withPrivateNat(t *testing.T) {
415
475
t.Parallel()
@@ -817,6 +877,40 @@ resource "google_compute_router_nat" "foobar" {
817
877
`, routerName, routerName, routerName, routerName, routerName)
818
878
}
819
879
880
+ func testAccComputeRouterNatUpdateEndpointType(routerName string, endpointType string) string {
881
+ return fmt.Sprintf(`
882
+ resource "google_compute_network" "foobar" {
883
+ name = "%[1]s-net"
884
+ }
885
+
886
+ resource "google_compute_subnetwork" "foobar" {
887
+ name = "%[1]s-subnet"
888
+ network = google_compute_network.foobar.self_link
889
+ ip_cidr_range = "10.0.0.0/16"
890
+ region = "us-central1"
891
+ }
892
+
893
+ resource "google_compute_router" "foobar" {
894
+ name = "%[1]s"
895
+ region = google_compute_subnetwork.foobar.region
896
+ network = google_compute_network.foobar.self_link
897
+ }
898
+
899
+ resource "google_compute_router_nat" "foobar" {
900
+ name = "%[1]s"
901
+ router = google_compute_router.foobar.name
902
+ region = google_compute_router.foobar.region
903
+ nat_ip_allocate_option = "AUTO_ONLY"
904
+ source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
905
+ endpoint_types = [ "%[2]s" ]
906
+ log_config {
907
+ enable = true
908
+ filter = "ERRORS_ONLY"
909
+ }
910
+ }
911
+ `, routerName, endpointType)
912
+ }
913
+
820
914
func testAccComputeRouterNatUpdateToNatIPsId(routerName string) string {
821
915
return fmt.Sprintf(`
822
916
resource "google_compute_router" "foobar" {
0 commit comments