@@ -30,7 +30,7 @@ func TestAccComputeRouterPeer_basic(t *testing.T) {
30
30
ResourceName : "google_compute_router_peer.foobar" ,
31
31
ImportState : true ,
32
32
ImportStateVerify : true ,
33
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
33
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
34
34
},
35
35
{
36
36
Config : testAccComputeRouterPeerKeepRouter (routerName ),
@@ -94,7 +94,7 @@ func TestAccComputeRouterPeer_enable(t *testing.T) {
94
94
ResourceName : "google_compute_router_peer.foobar" ,
95
95
ImportState : true ,
96
96
ImportStateVerify : true ,
97
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
97
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
98
98
},
99
99
{
100
100
Config : testAccComputeRouterPeerEnable (routerName , false ),
@@ -105,7 +105,7 @@ func TestAccComputeRouterPeer_enable(t *testing.T) {
105
105
ResourceName : "google_compute_router_peer.foobar" ,
106
106
ImportState : true ,
107
107
ImportStateVerify : true ,
108
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
108
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
109
109
},
110
110
{
111
111
Config : testAccComputeRouterPeerEnable (routerName , true ),
@@ -116,7 +116,7 @@ func TestAccComputeRouterPeer_enable(t *testing.T) {
116
116
ResourceName : "google_compute_router_peer.foobar" ,
117
117
ImportState : true ,
118
118
ImportStateVerify : true ,
119
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
119
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
120
120
},
121
121
},
122
122
})
@@ -140,7 +140,7 @@ func TestAccComputeRouterPeer_bfd(t *testing.T) {
140
140
ResourceName : "google_compute_router_peer.foobar" ,
141
141
ImportState : true ,
142
142
ImportStateVerify : true ,
143
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
143
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
144
144
},
145
145
{
146
146
Config : testAccComputeRouterPeerBfd (routerName , "DISABLED" ),
@@ -151,7 +151,7 @@ func TestAccComputeRouterPeer_bfd(t *testing.T) {
151
151
ResourceName : "google_compute_router_peer.foobar" ,
152
152
ImportState : true ,
153
153
ImportStateVerify : true ,
154
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
154
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
155
155
},
156
156
{
157
157
Config : testAccComputeRouterPeerBasic (routerName ),
@@ -162,7 +162,7 @@ func TestAccComputeRouterPeer_bfd(t *testing.T) {
162
162
ResourceName : "google_compute_router_peer.foobar" ,
163
163
ImportState : true ,
164
164
ImportStateVerify : true ,
165
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
165
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
166
166
},
167
167
},
168
168
})
@@ -214,7 +214,7 @@ func TestAccComputeRouterPeer_Ipv6Basic(t *testing.T) {
214
214
ResourceName : resourceName ,
215
215
ImportState : true ,
216
216
ImportStateVerify : true ,
217
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
217
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
218
218
},
219
219
},
220
220
})
@@ -242,7 +242,7 @@ func TestAccComputeRouterPeer_Ipv4BasicCreateUpdate(t *testing.T) {
242
242
ResourceName : resourceName ,
243
243
ImportState : true ,
244
244
ImportStateVerify : true ,
245
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
245
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
246
246
},
247
247
{
248
248
Config : testAccComputeRouterPeerUpdateIpv4Address (routerName ),
@@ -258,7 +258,7 @@ func TestAccComputeRouterPeer_Ipv4BasicCreateUpdate(t *testing.T) {
258
258
ResourceName : resourceName ,
259
259
ImportState : true ,
260
260
ImportStateVerify : true ,
261
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
261
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
262
262
},
263
263
},
264
264
})
@@ -291,6 +291,33 @@ func TestAccComputeRouterPeer_UpdateRouterCustomLearnedRoutePriority(t *testing.
291
291
})
292
292
}
293
293
294
+ func TestAccComputeRouterPeer_UpdateRouterAdvertisedRoutePriority (t * testing.T ) {
295
+ t .Parallel ()
296
+ routerName := fmt .Sprintf ("tf-test-router-%s" , acctest .RandString (t , 10 ))
297
+ resourceName := "google_compute_router_peer.peer"
298
+ acctest .VcrTest (t , resource.TestCase {
299
+ PreCheck : func () { acctest .AccTestPreCheck (t ) },
300
+ ProtoV5ProviderFactories : acctest .ProtoV5ProviderFactories (t ),
301
+ CheckDestroy : testAccCheckComputeRouterPeerDestroyProducer (t ),
302
+ Steps : []resource.TestStep {
303
+ {
304
+ Config : testAccComputeRouterPeerAdvertisedRoutePriority (routerName , 100 , false ),
305
+ Check : resource .ComposeTestCheckFunc (
306
+ resource .TestCheckResourceAttr (resourceName , "advertised_route_priority" , "100" ), // Check for one element in the list
307
+ ),
308
+ }, {
309
+ Config : testAccComputeRouterPeerAdvertisedRoutePriority (routerName , 0 , false ),
310
+ ExpectError : regexp .MustCompile (`Error: Invalid advertised_route_priority value: When zero_advertised_route_priority is set to 'false', the advertised_route_priority field cannot be 0. Please provide a non-zero value.` ), // Expect the specific error message
311
+ }, {
312
+ Config : testAccComputeRouterPeerAdvertisedRoutePriority (routerName , 0 , true ),
313
+ Check : resource .ComposeTestCheckFunc (
314
+ resource .TestCheckResourceAttr (resourceName , "advertised_route_priority" , "0" ),
315
+ ),
316
+ },
317
+ },
318
+ })
319
+ }
320
+
294
321
func TestAccComputeRouterPeer_UpdateIpv6Address (t * testing.T ) {
295
322
t .Parallel ()
296
323
@@ -313,7 +340,7 @@ func TestAccComputeRouterPeer_UpdateIpv6Address(t *testing.T) {
313
340
ResourceName : resourceName ,
314
341
ImportState : true ,
315
342
ImportStateVerify : true ,
316
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
343
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
317
344
},
318
345
{
319
346
Config : testAccComputeRouterPeerUpdateIpv6Address (routerName , true ),
@@ -327,7 +354,7 @@ func TestAccComputeRouterPeer_UpdateIpv6Address(t *testing.T) {
327
354
ResourceName : resourceName ,
328
355
ImportState : true ,
329
356
ImportStateVerify : true ,
330
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
357
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
331
358
},
332
359
},
333
360
})
@@ -355,7 +382,7 @@ func TestAccComputeRouterPeer_EnableDisableIpv6(t *testing.T) {
355
382
ResourceName : resourceName ,
356
383
ImportState : true ,
357
384
ImportStateVerify : true ,
358
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
385
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
359
386
},
360
387
{
361
388
Config : testAccComputeRouterPeerIpv6 (routerName , true ),
@@ -369,7 +396,7 @@ func TestAccComputeRouterPeer_EnableDisableIpv6(t *testing.T) {
369
396
ResourceName : resourceName ,
370
397
ImportState : true ,
371
398
ImportStateVerify : true ,
372
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
399
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
373
400
},
374
401
{
375
402
Config : testAccComputeRouterPeerIpv6 (routerName , false ),
@@ -383,7 +410,7 @@ func TestAccComputeRouterPeer_EnableDisableIpv6(t *testing.T) {
383
410
ResourceName : resourceName ,
384
411
ImportState : true ,
385
412
ImportStateVerify : true ,
386
- ImportStateVerifyIgnore : []string {"zero_custom_learned_route_priority" },
413
+ ImportStateVerifyIgnore : []string {"is_advertised_route_priority_set" , " zero_custom_learned_route_priority" },
387
414
},
388
415
},
389
416
})
@@ -878,6 +905,42 @@ func testAccComputeRouterPeerWithMd5AuthKeyUpdate(routerName string) string {
878
905
routerName , routerName )
879
906
}
880
907
908
+ func testAccComputeRouterPeerAdvertisedRoutePriority (routerName string , advertisedRoutePriority int , zeroAdvertisedRoutePriority bool ) string {
909
+ return fmt .Sprintf (`
910
+ resource "google_compute_network" "network" {
911
+ name = "%s-net"
912
+ auto_create_subnetworks = false
913
+ }
914
+
915
+ resource "google_compute_subnetwork" "subnetwork" {
916
+ name = "%s-sub"
917
+ network = google_compute_network.network.self_link
918
+ ip_cidr_range = "10.0.0.0/16"
919
+ region = "us-central1"
920
+ }
921
+
922
+ resource "google_compute_router" "router" {
923
+ name = "%s-router"
924
+ region = google_compute_subnetwork.subnetwork.region
925
+ network = google_compute_network.network.self_link
926
+ bgp {
927
+ asn = 64514
928
+ }
929
+ }
930
+
931
+ resource "google_compute_router_peer" "peer" {
932
+ name = "%s-router-peer"
933
+ router = google_compute_router.router.name
934
+ region = google_compute_router.router.region
935
+ interface = "interface-1"
936
+ peer_asn = 65513
937
+ advertised_route_priority = %d
938
+ zero_advertised_route_priority = %t
939
+ }
940
+ ` , routerName , routerName , routerName , routerName , advertisedRoutePriority , zeroAdvertisedRoutePriority )
941
+
942
+ }
943
+
881
944
func testAccComputeRouterPeerCustomLearnedRoutePriority (routerName string , customLearnedRoutePriority int , zeroCustomLearnedRoutePriority bool ) string {
882
945
return fmt .Sprintf (`
883
946
resource "google_compute_network" "network" {
@@ -911,7 +974,6 @@ resource "google_compute_router_peer" "peer" {
911
974
zero_custom_learned_route_priority = %t
912
975
}
913
976
` , routerName , routerName , routerName , routerName , customLearnedRoutePriority , zeroCustomLearnedRoutePriority )
914
-
915
977
}
916
978
917
979
func testAccComputeRouterPeerKeepRouter (routerName string ) string {
0 commit comments