Skip to content

Commit

Permalink
Send empty log_config value (#5154)
Browse files Browse the repository at this point in the history
  • Loading branch information
c2thorn authored Aug 31, 2021
1 parent fa6fec1 commit a9af7f4
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
1 change: 1 addition & 0 deletions mmv1/products/compute/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13226,6 +13226,7 @@ objects:
name: logConfig
description: |
Configuration for logging on NAT
send_empty_value: true
properties:
- !ruby/object:Api::Type::Boolean
name: 'enable'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,37 @@ func TestAccComputeRouterNat_update(t *testing.T) {
})
}

func TestAccComputeRouterNat_removeLogConfig(t *testing.T) {
t.Parallel()

testId := randString(t, 10)
routerName := fmt.Sprintf("tf-test-router-nat-%s", testId)

vcrTest(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckComputeRouterNatDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRouterNatLogConfig(routerName),
},
{
ResourceName: "google_compute_router_nat.foobar",
ImportState: true,
ImportStateVerify: true,
},
{
Config: testAccComputeRouterNatLogConfigRemoved(routerName),
},
{
ResourceName: "google_compute_router_nat.foobar",
ImportState: true,
ImportStateVerify: true,
},
},
})
}

func TestAccComputeRouterNat_withManualIpAndSubnetConfiguration(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -788,3 +819,65 @@ resource "google_compute_router" "foobar" {
}
`, routerName, routerName, routerName)
}

func testAccComputeRouterNatLogConfig(routerName string) string {
return fmt.Sprintf(`
resource "google_compute_network" "foobar" {
name = "%s-net"
}

resource "google_compute_subnetwork" "foobar" {
name = "%s-subnet"
network = google_compute_network.foobar.self_link
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
}

resource "google_compute_router" "foobar" {
name = "%s"
region = google_compute_subnetwork.foobar.region
network = google_compute_network.foobar.self_link
}

resource "google_compute_router_nat" "foobar" {
name = "%s"
router = google_compute_router.foobar.name
region = google_compute_router.foobar.region
nat_ip_allocate_option = "AUTO_ONLY"
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
log_config {
enable = false
filter = "ALL"
}
}
`, routerName, routerName, routerName, routerName)
}

func testAccComputeRouterNatLogConfigRemoved(routerName string) string {
return fmt.Sprintf(`
resource "google_compute_network" "foobar" {
name = "%s-net"
}

resource "google_compute_subnetwork" "foobar" {
name = "%s-subnet"
network = google_compute_network.foobar.self_link
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
}

resource "google_compute_router" "foobar" {
name = "%s"
region = google_compute_subnetwork.foobar.region
network = google_compute_network.foobar.self_link
}

resource "google_compute_router_nat" "foobar" {
name = "%s"
router = google_compute_router.foobar.name
region = google_compute_router.foobar.region
nat_ip_allocate_option = "AUTO_ONLY"
source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
}
`, routerName, routerName, routerName, routerName)
}

0 comments on commit a9af7f4

Please sign in to comment.