@@ -37,6 +37,29 @@ func TestAccComputeRouterPeer_basic(t *testing.T) {
37
37
})
38
38
}
39
39
40
+ func TestAccComputeRouterPeer_advertiseMode (t * testing.T ) {
41
+ t .Parallel ()
42
+
43
+ testId := acctest .RandString (10 )
44
+ resource .Test (t , resource.TestCase {
45
+ PreCheck : func () { testAccPreCheck (t ) },
46
+ Providers : testAccProviders ,
47
+ CheckDestroy : testAccCheckComputeRouterPeerDestroy ,
48
+ Steps : []resource.TestStep {
49
+ {
50
+ Config : testAccComputeRouterPeerAdvertiseMode (testId ),
51
+ Check : testAccCheckComputeRouterPeerExists (
52
+ "google_compute_router_peer.foobar" ),
53
+ },
54
+ {
55
+ ResourceName : "google_compute_router_peer.foobar" ,
56
+ ImportState : true ,
57
+ ImportStateVerify : true ,
58
+ },
59
+ },
60
+ })
61
+ }
62
+
40
63
func testAccCheckComputeRouterPeerDestroy (s * terraform.State ) error {
41
64
config := testAccProvider .Meta ().(* Config )
42
65
@@ -303,3 +326,86 @@ func testAccComputeRouterPeerKeepRouter(testId string) string {
303
326
}
304
327
` , testId , testId , testId , testId , testId , testId , testId , testId , testId , testId )
305
328
}
329
+
330
+ func testAccComputeRouterPeerAdvertiseMode (testId string ) string {
331
+ return fmt .Sprintf (`
332
+ resource "google_compute_network" "foobar" {
333
+ name = "router-peer-test-%s"
334
+ }
335
+ resource "google_compute_subnetwork" "foobar" {
336
+ name = "router-peer-test-subnetwork-%s"
337
+ network = "${google_compute_network.foobar.self_link}"
338
+ ip_cidr_range = "10.0.0.0/16"
339
+ region = "us-central1"
340
+ }
341
+ resource "google_compute_address" "foobar" {
342
+ name = "router-peer-test-%s"
343
+ region = "${google_compute_subnetwork.foobar.region}"
344
+ }
345
+ resource "google_compute_vpn_gateway" "foobar" {
346
+ name = "router-peer-test-%s"
347
+ network = "${google_compute_network.foobar.self_link}"
348
+ region = "${google_compute_subnetwork.foobar.region}"
349
+ }
350
+ resource "google_compute_forwarding_rule" "foobar_esp" {
351
+ name = "router-peer-test-%s-1"
352
+ region = "${google_compute_vpn_gateway.foobar.region}"
353
+ ip_protocol = "ESP"
354
+ ip_address = "${google_compute_address.foobar.address}"
355
+ target = "${google_compute_vpn_gateway.foobar.self_link}"
356
+ }
357
+ resource "google_compute_forwarding_rule" "foobar_udp500" {
358
+ name = "router-peer-test-%s-2"
359
+ region = "${google_compute_forwarding_rule.foobar_esp.region}"
360
+ ip_protocol = "UDP"
361
+ port_range = "500-500"
362
+ ip_address = "${google_compute_address.foobar.address}"
363
+ target = "${google_compute_vpn_gateway.foobar.self_link}"
364
+ }
365
+ resource "google_compute_forwarding_rule" "foobar_udp4500" {
366
+ name = "router-peer-test-%s-3"
367
+ region = "${google_compute_forwarding_rule.foobar_udp500.region}"
368
+ ip_protocol = "UDP"
369
+ port_range = "4500-4500"
370
+ ip_address = "${google_compute_address.foobar.address}"
371
+ target = "${google_compute_vpn_gateway.foobar.self_link}"
372
+ }
373
+ resource "google_compute_router" "foobar"{
374
+ name = "router-peer-test-%s"
375
+ region = "${google_compute_forwarding_rule.foobar_udp500.region}"
376
+ network = "${google_compute_network.foobar.self_link}"
377
+ bgp {
378
+ asn = 64514
379
+ }
380
+ }
381
+ resource "google_compute_vpn_tunnel" "foobar" {
382
+ name = "router-peer-test-%s"
383
+ region = "${google_compute_forwarding_rule.foobar_udp4500.region}"
384
+ target_vpn_gateway = "${google_compute_vpn_gateway.foobar.self_link}"
385
+ shared_secret = "unguessable"
386
+ peer_ip = "8.8.8.8"
387
+ router = "${google_compute_router.foobar.name}"
388
+ }
389
+ resource "google_compute_router_interface" "foobar" {
390
+ name = "router-peer-test-%s"
391
+ router = "${google_compute_router.foobar.name}"
392
+ region = "${google_compute_router.foobar.region}"
393
+ ip_range = "169.254.3.1/30"
394
+ vpn_tunnel = "${google_compute_vpn_tunnel.foobar.name}"
395
+ }
396
+ resource "google_compute_router_peer" "foobar" {
397
+ name = "router-peer-test-%s"
398
+ router = "${google_compute_router.foobar.name}"
399
+ region = "${google_compute_router.foobar.region}"
400
+ peer_ip_address = "169.254.3.2"
401
+ peer_asn = 65515
402
+ advertised_route_priority = 100
403
+ advertise_mode = "CUSTOM"
404
+ advertised_groups = ["ALL_SUBNETS"]
405
+ advertised_ip_ranges {
406
+ range = "10.1.0.0/32"
407
+ }
408
+ interface = "${google_compute_router_interface.foobar.name}"
409
+ }
410
+ ` , testId , testId , testId , testId , testId , testId , testId , testId , testId , testId , testId )
411
+ }
0 commit comments