88 "testing"
99
1010 "github.com/hashicorp/terraform-plugin-testing/helper/resource"
11+ "github.com/hashicorp/terraform-plugin-testing/plancheck"
1112 "github.com/hashicorp/terraform-plugin-testing/terraform"
1213 "github.com/hashicorp/terraform-provider-google-beta/google-beta/acctest"
1314 "github.com/hashicorp/terraform-provider-google-beta/google-beta/envvar"
@@ -84,6 +85,11 @@ func TestAccComputeRouterNat_update(t *testing.T) {
8485 },
8586 {
8687 Config : testAccComputeRouterNatUpdated (routerName ),
88+ ConfigPlanChecks : resource.ConfigPlanChecks {
89+ PreApply : []plancheck.PlanCheck {
90+ plancheck .ExpectResourceAction ("google_compute_router_nat.foobar" , plancheck .ResourceActionUpdate ),
91+ },
92+ },
8793 },
8894 {
8995 ResourceName : "google_compute_router_nat.foobar" ,
@@ -92,6 +98,11 @@ func TestAccComputeRouterNat_update(t *testing.T) {
9298 },
9399 {
94100 Config : testAccComputeRouterNatUpdateToNatIPsId (routerName ),
101+ ConfigPlanChecks : resource.ConfigPlanChecks {
102+ PreApply : []plancheck.PlanCheck {
103+ plancheck .ExpectResourceAction ("google_compute_router_nat.foobar" , plancheck .ResourceActionNoop ),
104+ },
105+ },
95106 },
96107 {
97108 ResourceName : "google_compute_router_nat.foobar" ,
@@ -100,6 +111,11 @@ func TestAccComputeRouterNat_update(t *testing.T) {
100111 },
101112 {
102113 Config : testAccComputeRouterNatUpdateToNatIPsName (routerName ),
114+ ConfigPlanChecks : resource.ConfigPlanChecks {
115+ PreApply : []plancheck.PlanCheck {
116+ plancheck .ExpectResourceAction ("google_compute_router_nat.foobar" , plancheck .ResourceActionNoop ),
117+ },
118+ },
103119 },
104120 {
105121 ResourceName : "google_compute_router_nat.foobar" ,
@@ -108,37 +124,11 @@ func TestAccComputeRouterNat_update(t *testing.T) {
108124 },
109125 {
110126 Config : testAccComputeRouterNatBasicBeforeUpdate (routerName ),
111- },
112- {
113- ResourceName : "google_compute_router_nat.foobar" ,
114- ImportState : true ,
115- ImportStateVerify : true ,
116- },
117- },
118- })
119- }
120-
121- func TestAccComputeRouterNat_removeLogConfig (t * testing.T ) {
122- t .Parallel ()
123-
124- testId := acctest .RandString (t , 10 )
125- routerName := fmt .Sprintf ("tf-test-router-nat-%s" , testId )
126-
127- acctest .VcrTest (t , resource.TestCase {
128- PreCheck : func () { acctest .AccTestPreCheck (t ) },
129- ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
130- CheckDestroy : testAccCheckComputeRouterNatDestroyProducer (t ),
131- Steps : []resource.TestStep {
132- {
133- Config : testAccComputeRouterNatLogConfig (routerName ),
134- },
135- {
136- ResourceName : "google_compute_router_nat.foobar" ,
137- ImportState : true ,
138- ImportStateVerify : true ,
139- },
140- {
141- Config : testAccComputeRouterNatLogConfigRemoved (routerName ),
127+ ConfigPlanChecks : resource.ConfigPlanChecks {
128+ PreApply : []plancheck.PlanCheck {
129+ plancheck .ExpectResourceAction ("google_compute_router_nat.foobar" , plancheck .ResourceActionUpdate ),
130+ },
131+ },
142132 },
143133 {
144134 ResourceName : "google_compute_router_nat.foobar" ,
@@ -1011,6 +1001,7 @@ resource "google_compute_router" "foobar" {
10111001
10121002resource "google_compute_network" "foobar" {
10131003 name = "%s-net"
1004+ auto_create_subnetworks = false
10141005}
10151006
10161007resource "google_compute_subnetwork" "foobar" {
@@ -1032,11 +1023,6 @@ resource "google_compute_router_nat" "foobar" {
10321023 nat_ip_allocate_option = "AUTO_ONLY"
10331024 nat_ips = []
10341025 source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
1035-
1036- log_config {
1037- enable = true
1038- filter = "ERRORS_ONLY"
1039- }
10401026}
10411027` , routerName , routerName , routerName , routerName , routerName )
10421028}
@@ -1051,6 +1037,7 @@ resource "google_compute_router" "foobar" {
10511037
10521038resource "google_compute_network" "foobar" {
10531039 name = "%s-net"
1040+ auto_create_subnetworks = false
10541041}
10551042
10561043resource "google_compute_subnetwork" "foobar" {
@@ -1085,6 +1072,7 @@ resource "google_compute_router_nat" "foobar" {
10851072 tcp_established_idle_timeout_sec = 1600
10861073 tcp_transitory_idle_timeout_sec = 60
10871074 tcp_time_wait_timeout_sec = 60
1075+ max_ports_per_vm = 128
10881076
10891077 log_config {
10901078 enable = true
@@ -1137,7 +1125,8 @@ network = google_compute_network.foobar.self_link
11371125}
11381126
11391127resource "google_compute_network" "foobar" {
1140- name = "%s-net"
1128+ name = "%s-net"
1129+ auto_create_subnetworks = false
11411130}
11421131resource "google_compute_subnetwork" "foobar" {
11431132name = "%s-subnet"
@@ -1171,6 +1160,7 @@ resource "google_compute_router_nat" "foobar" {
11711160 tcp_established_idle_timeout_sec = 1600
11721161 tcp_transitory_idle_timeout_sec = 60
11731162 tcp_time_wait_timeout_sec = 60
1163+ max_ports_per_vm = 128
11741164
11751165 log_config {
11761166 enable = true
@@ -1189,7 +1179,8 @@ network = google_compute_network.foobar.self_link
11891179}
11901180
11911181resource "google_compute_network" "foobar" {
1192- name = "%s-net"
1182+ name = "%s-net"
1183+ auto_create_subnetworks = false
11931184}
11941185resource "google_compute_subnetwork" "foobar" {
11951186name = "%s-subnet"
@@ -1223,6 +1214,7 @@ resource "google_compute_router_nat" "foobar" {
12231214 tcp_established_idle_timeout_sec = 1600
12241215 tcp_transitory_idle_timeout_sec = 60
12251216 tcp_time_wait_timeout_sec = 60
1217+ max_ports_per_vm = 128
12261218
12271219 log_config {
12281220 enable = true
@@ -1826,68 +1818,6 @@ resource "google_compute_router" "foobar" {
18261818` , routerName , routerName , routerName )
18271819}
18281820
1829- func testAccComputeRouterNatLogConfig (routerName string ) string {
1830- return fmt .Sprintf (`
1831- resource "google_compute_network" "foobar" {
1832- name = "%s-net"
1833- }
1834-
1835- resource "google_compute_subnetwork" "foobar" {
1836- name = "%s-subnet"
1837- network = google_compute_network.foobar.self_link
1838- ip_cidr_range = "10.0.0.0/16"
1839- region = "us-central1"
1840- }
1841-
1842- resource "google_compute_router" "foobar" {
1843- name = "%s"
1844- region = google_compute_subnetwork.foobar.region
1845- network = google_compute_network.foobar.self_link
1846- }
1847-
1848- resource "google_compute_router_nat" "foobar" {
1849- name = "%s"
1850- router = google_compute_router.foobar.name
1851- region = google_compute_router.foobar.region
1852- nat_ip_allocate_option = "AUTO_ONLY"
1853- source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
1854- log_config {
1855- enable = false
1856- filter = "ALL"
1857- }
1858- }
1859- ` , routerName , routerName , routerName , routerName )
1860- }
1861-
1862- func testAccComputeRouterNatLogConfigRemoved (routerName string ) string {
1863- return fmt .Sprintf (`
1864- resource "google_compute_network" "foobar" {
1865- name = "%s-net"
1866- }
1867-
1868- resource "google_compute_subnetwork" "foobar" {
1869- name = "%s-subnet"
1870- network = google_compute_network.foobar.self_link
1871- ip_cidr_range = "10.0.0.0/16"
1872- region = "us-central1"
1873- }
1874-
1875- resource "google_compute_router" "foobar" {
1876- name = "%s"
1877- region = google_compute_subnetwork.foobar.region
1878- network = google_compute_network.foobar.self_link
1879- }
1880-
1881- resource "google_compute_router_nat" "foobar" {
1882- name = "%s"
1883- router = google_compute_router.foobar.name
1884- region = google_compute_router.foobar.region
1885- nat_ip_allocate_option = "AUTO_ONLY"
1886- source_subnetwork_ip_ranges_to_nat = "ALL_SUBNETWORKS_ALL_IP_RANGES"
1887- }
1888- ` , routerName , routerName , routerName , routerName )
1889- }
1890-
18911821func testAccComputeRouterNatBaseResourcesWithPrivateNatSubnetworks (routerName , hubName string ) string {
18921822 return fmt .Sprintf (`
18931823resource "google_compute_network" "foobar" {
0 commit comments