@@ -114,6 +114,37 @@ func TestAccComputeRouterNat_update(t *testing.T) {
114114 })
115115}
116116
117+ func TestAccComputeRouterNat_removeLogConfig (t * testing.T ) {
118+ t .Parallel ()
119+
120+ testId := randString (t , 10 )
121+ routerName := fmt .Sprintf ("tf-test-router-nat-%s" , testId )
122+
123+ vcrTest (t , resource.TestCase {
124+ PreCheck : func () { testAccPreCheck (t ) },
125+ Providers : testAccProviders ,
126+ CheckDestroy : testAccCheckComputeRouterNatDestroyProducer (t ),
127+ Steps : []resource.TestStep {
128+ {
129+ Config : testAccComputeRouterNatLogConfig (routerName ),
130+ },
131+ {
132+ ResourceName : "google_compute_router_nat.foobar" ,
133+ ImportState : true ,
134+ ImportStateVerify : true ,
135+ },
136+ {
137+ Config : testAccComputeRouterNatLogConfigRemoved (routerName ),
138+ },
139+ {
140+ ResourceName : "google_compute_router_nat.foobar" ,
141+ ImportState : true ,
142+ ImportStateVerify : true ,
143+ },
144+ },
145+ })
146+ }
147+
117148func TestAccComputeRouterNat_withManualIpAndSubnetConfiguration (t * testing.T ) {
118149 t .Parallel ()
119150
@@ -781,3 +812,65 @@ resource "google_compute_router" "foobar" {
781812}
782813` , routerName , routerName , routerName )
783814}
815+
816+ func testAccComputeRouterNatLogConfig (routerName string ) string {
817+ return fmt .Sprintf (`
818+ resource "google_compute_network" "foobar" {
819+ name = "%s-net"
820+ }
821+
822+ resource "google_compute_subnetwork" "foobar" {
823+ name = "%s-subnet"
824+ network = google_compute_network.foobar.self_link
825+ ip_cidr_range = "10.0.0.0/16"
826+ region = "us-central1"
827+ }
828+
829+ resource "google_compute_router" "foobar" {
830+ name = "%s"
831+ region = google_compute_subnetwork.foobar.region
832+ network = google_compute_network.foobar.self_link
833+ }
834+
835+ resource "google_compute_router_nat" "foobar" {
836+ name = "%s"
837+ router = google_compute_router.foobar.name
838+ region = google_compute_router.foobar.region
839+ nat_ip_allocate_option = "AUTO_ONLY"
840+ source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
841+ log_config {
842+ enable = false
843+ filter = "ALL"
844+ }
845+ }
846+ ` , routerName , routerName , routerName , routerName )
847+ }
848+
849+ func testAccComputeRouterNatLogConfigRemoved (routerName string ) string {
850+ return fmt .Sprintf (`
851+ resource "google_compute_network" "foobar" {
852+ name = "%s-net"
853+ }
854+
855+ resource "google_compute_subnetwork" "foobar" {
856+ name = "%s-subnet"
857+ network = google_compute_network.foobar.self_link
858+ ip_cidr_range = "10.0.0.0/16"
859+ region = "us-central1"
860+ }
861+
862+ resource "google_compute_router" "foobar" {
863+ name = "%s"
864+ region = google_compute_subnetwork.foobar.region
865+ network = google_compute_network.foobar.self_link
866+ }
867+
868+ resource "google_compute_router_nat" "foobar" {
869+ name = "%s"
870+ router = google_compute_router.foobar.name
871+ region = google_compute_router.foobar.region
872+ nat_ip_allocate_option = "AUTO_ONLY"
873+ source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
874+ }
875+ ` , routerName , routerName , routerName , routerName )
876+ }
0 commit comments