Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permadiff fix: advertised_ip_ranges in cloud router #11262

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func flatten<%= prefix -%><%= titlelize_property(property) -%>(v interface{}, d
})
}
configData := []map[string]interface{}{}
if v, ok := d.GetOk("advertised_ip_ranges"); ok {
if v, ok := d.GetOk("bgp.0.advertised_ip_ranges"); ok {
for _, item := range v.([]interface{}) {
configData = append(configData, item.(map[string]interface{}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,29 @@ func TestAccComputeRouter_full(t *testing.T) {
})
}

func TestAccComputeRouter_advertisedIpRangesOrder(t *testing.T) {
t.Parallel()

testId := acctest.RandString(t, 10)
routerName := fmt.Sprintf("tf-test-router-%s", testId)
acctest.VcrTest(t, resource.TestCase{
PreCheck: func() { acctest.AccTestPreCheck(t) },
ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t),
CheckDestroy: testAccCheckComputeRouterDestroyProducer(t),
Steps: []resource.TestStep{
{
Config: testAccComputeRouterAdvertisedIpRangesOrder(routerName),
},
{
ResourceName: "google_compute_router.foobar",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"bgp.0.advertised_ip_ranges.0.range", "bgp.0.advertised_ip_ranges.1.range"},
},
},
})
}

func TestAccComputeRouter_update(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -264,6 +287,32 @@ resource "google_compute_router" "foobar" {
`, routerName, routerName)
}

func testAccComputeRouterAdvertisedIpRangesOrder(routerName string) string {
return fmt.Sprintf(`
resource "google_compute_network" "foobar" {
name = "%s-net"
auto_create_subnetworks = false
}

resource "google_compute_router" "foobar" {
name = "%s"
network = google_compute_network.foobar.name
bgp {
asn = 64514
advertise_mode = "CUSTOM"
advertised_groups = ["ALL_SUBNETS"]
advertised_ip_ranges {
range = "6.7.0.0/16"
}
advertised_ip_ranges {
range = "1.2.3.4"
}
keepalive_interval = 25
}
}
`, routerName, routerName)
}

func testAccComputeRouter_noBGP(routerName, resourceRegion string) string {
return fmt.Sprintf(`
resource "google_compute_network" "foobar" {
Expand Down
Loading