From 0e2a57548455aa747ee30ed79b25c3404fec5297 Mon Sep 17 00:00:00 2001 From: Cameron Thornton Date: Tue, 31 Aug 2021 13:53:26 -0500 Subject: [PATCH] Send empty log_config value (#5154) --- mmv1/products/compute/api.yaml | 1 + .../resource_compute_router_nat_test.go.erb | 93 +++++++++++++++++++ 2 files changed, 94 insertions(+) diff --git a/mmv1/products/compute/api.yaml b/mmv1/products/compute/api.yaml index 442bdd4e072b..d669d87983d9 100644 --- a/mmv1/products/compute/api.yaml +++ b/mmv1/products/compute/api.yaml @@ -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' diff --git a/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb b/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb index 07a2a8c474c2..3f4a12d56e17 100644 --- a/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb +++ b/mmv1/third_party/terraform/tests/resource_compute_router_nat_test.go.erb @@ -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() @@ -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) +} \ No newline at end of file