Skip to content

Commit 7c018f4

Browse files
matheusaleixo-citpcostell
authored andcommitted
Added "endpointTypes" support to compute router nat resource (GoogleCloudPlatform#10338)
1 parent ac20a46 commit 7c018f4

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

mmv1/products/compute/RouterNat.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,17 @@ properties:
308308
- :ERRORS_ONLY
309309
- :TRANSLATIONS_ONLY
310310
- :ALL
311+
- !ruby/object:Api::Type::Array
312+
name: 'endpointTypes'
313+
immutable: true
314+
min_size: 1
315+
description: |
316+
Specifies the endpoint Types supported by the NAT Gateway.
317+
Supported values include:
318+
`ENDPOINT_TYPE_VM`, `ENDPOINT_TYPE_SWG`,
319+
`ENDPOINT_TYPE_MANAGED_PROXY_LB`.
320+
default_from_api: true
321+
item_type: Api::Type::String
311322
- !ruby/object:Api::Type::Array
312323
name: rules
313324
description: 'A list of rules associated with this NAT.'

mmv1/third_party/terraform/services/compute/resource_compute_router_nat_test.go.erb

+94
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,66 @@ func TestAccComputeRouterNat_withNatRules(t *testing.T) {
410410
})
411411
}
412412

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+
413473
<% unless version == 'ga' -%>
414474
func TestAccComputeRouterNat_withPrivateNat(t *testing.T) {
415475
t.Parallel()
@@ -817,6 +877,40 @@ resource "google_compute_router_nat" "foobar" {
817877
`, routerName, routerName, routerName, routerName, routerName)
818878
}
819879

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+
820914
func testAccComputeRouterNatUpdateToNatIPsId(routerName string) string {
821915
return fmt.Sprintf(`
822916
resource "google_compute_router" "foobar" {

0 commit comments

Comments
 (0)