From b39972aa2871a367b1d2c56819a2d923eae7daf9 Mon Sep 17 00:00:00 2001 From: Modular Magician Date: Wed, 8 May 2024 22:34:02 +0000 Subject: [PATCH] Removing version guards for fields going GA (#10613) [upstream:6a4797785c1fca97572795018e6102801f995d6b] Signed-off-by: Modular Magician --- .../compute/resource_compute_router.go | 27 +++ .../resource_compute_router_bgp_peer_test.go | 198 ++++++++++++++++++ .../resource_compute_router_interface.go | 16 ++ .../resource_compute_router_interface_test.go | 106 ++++++++++ .../compute/resource_compute_router_peer.go | 89 ++++++++ .../compute/resource_compute_router_test.go | 87 ++++++++ website/docs/r/compute_router.html.markdown | 2 +- .../r/compute_router_interface.html.markdown | 2 +- .../docs/r/compute_router_peer.html.markdown | 6 +- 9 files changed, 528 insertions(+), 5 deletions(-) diff --git a/google/services/compute/resource_compute_router.go b/google/services/compute/resource_compute_router.go index 6b629aace6d..c7460369b54 100644 --- a/google/services/compute/resource_compute_router.go +++ b/google/services/compute/resource_compute_router.go @@ -154,6 +154,16 @@ CIDR-formatted string.`, }, }, }, + "identifier_range": { + Type: schema.TypeString, + Computed: true, + Optional: true, + Description: `Explicitly specifies a range of valid BGP Identifiers for this Router. +It is provided as a link-local IPv4 range (from 169.254.0.0/16), of +size at least /30, even if the BGP sessions are over IPv6. It must +not overlap with any IPv4 BGP session ranges. Other vendors commonly +call this router ID.`, + }, "keepalive_interval": { Type: schema.TypeInt, Optional: true, @@ -589,6 +599,8 @@ func flattenComputeRouterBgp(v interface{}, d *schema.ResourceData, config *tran flattenComputeRouterBgpAdvertisedIpRanges(original["advertisedIpRanges"], d, config) transformed["keepalive_interval"] = flattenComputeRouterBgpKeepaliveInterval(original["keepaliveInterval"], d, config) + transformed["identifier_range"] = + flattenComputeRouterBgpIdentifierRange(original["identifierRange"], d, config) return []interface{}{transformed} } func flattenComputeRouterBgpAsn(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { @@ -660,6 +672,10 @@ func flattenComputeRouterBgpKeepaliveInterval(v interface{}, d *schema.ResourceD return v // let terraform core handle it otherwise } +func flattenComputeRouterBgpIdentifierRange(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenComputeRouterEncryptedInterconnectRouter(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -731,6 +747,13 @@ func expandComputeRouterBgp(v interface{}, d tpgresource.TerraformResourceData, transformed["keepaliveInterval"] = transformedKeepaliveInterval } + transformedIdentifierRange, err := expandComputeRouterBgpIdentifierRange(original["identifier_range"], d, config) + if err != nil { + return nil, err + } else if val := reflect.ValueOf(transformedIdentifierRange); val.IsValid() && !tpgresource.IsEmptyValue(val) { + transformed["identifierRange"] = transformedIdentifierRange + } + return transformed, nil } @@ -787,6 +810,10 @@ func expandComputeRouterBgpKeepaliveInterval(v interface{}, d tpgresource.Terraf return v, nil } +func expandComputeRouterBgpIdentifierRange(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandComputeRouterEncryptedInterconnectRouter(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/google/services/compute/resource_compute_router_bgp_peer_test.go b/google/services/compute/resource_compute_router_bgp_peer_test.go index 6dc9efb4690..7416d81cdd5 100644 --- a/google/services/compute/resource_compute_router_bgp_peer_test.go +++ b/google/services/compute/resource_compute_router_bgp_peer_test.go @@ -208,6 +208,48 @@ func TestAccComputeRouterPeer_Ipv6Basic(t *testing.T) { }) } +func TestAccComputeRouterPeer_Ipv4BasicCreateUpdate(t *testing.T) { + t.Parallel() + + routerName := fmt.Sprintf("tf-test-router-%s", acctest.RandString(t, 10)) + resourceName := "google_compute_router_peer.foobar" + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckComputeRouterPeerDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeRouterPeerIpv4(routerName), + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeRouterPeerExists( + t, resourceName), + resource.TestCheckResourceAttr(resourceName, "enable_ipv4", "true"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComputeRouterPeerUpdateIpv4Address(routerName), + Check: resource.ComposeTestCheckFunc( + testAccCheckComputeRouterPeerExists( + t, resourceName), + resource.TestCheckResourceAttr(resourceName, "enable_ipv4", "true"), + resource.TestCheckResourceAttr(resourceName, "ipv4_nexthop_address", "169.254.1.2"), + resource.TestCheckResourceAttr(resourceName, "peer_ipv4_nexthop_address", "169.254.1.1"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func TestAccComputeRouterPeer_UpdateIpv6Address(t *testing.T) { t.Parallel() @@ -1503,3 +1545,159 @@ resource "google_compute_router_peer" "foobar" { } `, routerName, routerName, routerName, routerName, routerName, routerName, routerName, routerName, enableIpv6) } + +func testAccComputeRouterPeerIpv4(routerName string) string { + return fmt.Sprintf(`resource "google_compute_network" "foobar" { + name = "%s-net" + auto_create_subnetworks = false + } + + resource "google_compute_subnetwork" "foobar" { + name = "%s-subnet" + network = google_compute_network.foobar.self_link + ip_cidr_range = "10.0.0.0/16" + region = "us-central1" + stack_type = "IPV4_IPV6" + ipv6_access_type = "EXTERNAL" + } + + resource "google_compute_ha_vpn_gateway" "foobar" { + name = "%s-gateway" + network = google_compute_network.foobar.self_link + region = google_compute_subnetwork.foobar.region + stack_type = "IPV4_IPV6" + } + + resource "google_compute_external_vpn_gateway" "external_gateway" { + name = "%s-external-gateway" + redundancy_type = "SINGLE_IP_INTERNALLY_REDUNDANT" + description = "An externally managed VPN gateway" + interface { + id = 0 + ip_address = "8.8.8.8" + } + } + + resource "google_compute_router" "foobar" { + name = "%s" + region = google_compute_subnetwork.foobar.region + network = google_compute_network.foobar.self_link + bgp { + asn = 64514 + } + } + + resource "google_compute_vpn_tunnel" "foobar" { + name = "%s-tunnel" + region = google_compute_subnetwork.foobar.region + vpn_gateway = google_compute_ha_vpn_gateway.foobar.id + peer_external_gateway = google_compute_external_vpn_gateway.external_gateway.id + peer_external_gateway_interface = 0 + shared_secret = "unguessable" + router = google_compute_router.foobar.name + vpn_gateway_interface = 0 + } + + resource "google_compute_router_interface" "foobar" { + name = "%s-interface" + router = google_compute_router.foobar.name + region = google_compute_router.foobar.region + vpn_tunnel = google_compute_vpn_tunnel.foobar.name + ip_range = "fdff:1::1:1/126" + } + + resource "google_compute_router_peer" "foobar" { + name = "%s-peer" + router = google_compute_router.foobar.name + region = google_compute_router.foobar.region + peer_asn = 65515 + advertised_route_priority = 100 + interface = google_compute_router_interface.foobar.name + ip_address = "fdff:1::1:1" + peer_ip_address = "fdff:1::1:2" + + enable_ipv4 = true + enable_ipv6 = true + ipv4_nexthop_address = "169.254.1.1" + peer_ipv4_nexthop_address = "169.254.1.2" + } + `, routerName, routerName, routerName, routerName, routerName, routerName, routerName, routerName) +} + +func testAccComputeRouterPeerUpdateIpv4Address(routerName string) string { + return fmt.Sprintf(`resource "google_compute_network" "foobar" { + name = "%s-net" + auto_create_subnetworks = false + } + + resource "google_compute_subnetwork" "foobar" { + name = "%s-subnet" + network = google_compute_network.foobar.self_link + ip_cidr_range = "10.0.0.0/16" + region = "us-central1" + stack_type = "IPV4_IPV6" + ipv6_access_type = "EXTERNAL" + } + + resource "google_compute_ha_vpn_gateway" "foobar" { + name = "%s-gateway" + network = google_compute_network.foobar.self_link + region = google_compute_subnetwork.foobar.region + stack_type = "IPV4_IPV6" + } + + resource "google_compute_external_vpn_gateway" "external_gateway" { + name = "%s-external-gateway" + redundancy_type = "SINGLE_IP_INTERNALLY_REDUNDANT" + description = "An externally managed VPN gateway" + interface { + id = 0 + ip_address = "8.8.8.8" + } + } + + resource "google_compute_router" "foobar" { + name = "%s" + region = google_compute_subnetwork.foobar.region + network = google_compute_network.foobar.self_link + bgp { + asn = 64514 + } + } + + resource "google_compute_vpn_tunnel" "foobar" { + name = "%s-tunnel" + region = google_compute_subnetwork.foobar.region + vpn_gateway = google_compute_ha_vpn_gateway.foobar.id + peer_external_gateway = google_compute_external_vpn_gateway.external_gateway.id + peer_external_gateway_interface = 0 + shared_secret = "unguessable" + router = google_compute_router.foobar.name + vpn_gateway_interface = 0 + } + + resource "google_compute_router_interface" "foobar" { + name = "%s-interface" + router = google_compute_router.foobar.name + region = google_compute_router.foobar.region + vpn_tunnel = google_compute_vpn_tunnel.foobar.name + ip_range = "fdff:1::1:1/126" + } + + resource "google_compute_router_peer" "foobar" { + name = "%s-peer" + router = google_compute_router.foobar.name + region = google_compute_router.foobar.region + peer_asn = 65515 + advertised_route_priority = 100 + interface = google_compute_router_interface.foobar.name + ip_address = "fdff:1::1:1" + peer_ip_address = "fdff:1::1:2" + + enable_ipv4 = true + enable_ipv6 = true + ipv4_nexthop_address = "169.254.1.2" + peer_ipv4_nexthop_address = "169.254.1.1" + } + `, routerName, routerName, routerName, routerName, routerName, routerName, routerName, routerName) +} diff --git a/google/services/compute/resource_compute_router_interface.go b/google/services/compute/resource_compute_router_interface.go index a2b504821d8..7a0833fb66d 100644 --- a/google/services/compute/resource_compute_router_interface.go +++ b/google/services/compute/resource_compute_router_interface.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/customdiff" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/hashicorp/terraform-provider-google/google/verify" "google.golang.org/api/googleapi" "google.golang.org/api/compute/v1" @@ -77,6 +78,14 @@ func ResourceComputeRouterInterface() *schema.Resource { AtLeastOneOf: []string{"ip_range", "interconnect_attachment", "subnetwork", "vpn_tunnel"}, Description: `The IP address and range of the interface. The IP range must be in the RFC3927 link-local IP space. Changing this forces a new interface to be created.`, }, + "ip_version": { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + Computed: true, + ValidateFunc: verify.ValidateEnum([]string{"IPV4", "IPV6"}), + Description: `IP version of this interface.`, + }, "private_ip_address": { Type: schema.TypeString, Optional: true, @@ -175,6 +184,10 @@ func resourceComputeRouterInterfaceCreate(d *schema.ResourceData, meta interface iface.IpRange = ipRangeVal.(string) } + if ipVersionVal, ok := d.GetOk("ip_version"); ok { + iface.IpVersion = ipVersionVal.(string) + } + if privateIpVal, ok := d.GetOk("private_ip_address"); ok { iface.PrivateIpAddress = privateIpVal.(string) } @@ -266,6 +279,9 @@ func resourceComputeRouterInterfaceRead(d *schema.ResourceData, meta interface{} if err := d.Set("ip_range", iface.IpRange); err != nil { return fmt.Errorf("Error setting ip_range: %s", err) } + if err := d.Set("ip_version", iface.IpVersion); err != nil { + return fmt.Errorf("Error setting ip_version: %s", err) + } if err := d.Set("private_ip_address", iface.PrivateIpAddress); err != nil { return fmt.Errorf("Error setting private_ip_address: %s", err) } diff --git a/google/services/compute/resource_compute_router_interface_test.go b/google/services/compute/resource_compute_router_interface_test.go index 6aabeea0315..7e8a2a41118 100644 --- a/google/services/compute/resource_compute_router_interface_test.go +++ b/google/services/compute/resource_compute_router_interface_test.go @@ -121,6 +121,52 @@ func TestAccComputeRouterInterface_withPrivateIpAddress(t *testing.T) { }) } +func TestAccComputeRouterInterface_withIPVersionV4(t *testing.T) { + t.Parallel() + + routerName := fmt.Sprintf("tf-test-router-%s", acctest.RandString(t, 10)) + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckComputeRouterInterfaceDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeRouterInterfaceWithIpVersionIPV4(routerName), + Check: testAccCheckComputeRouterInterfaceExists( + t, "google_compute_router_interface.foobar"), + }, + { + ResourceName: "google_compute_router_interface.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + +func TestAccComputeRouterInterface_withIPVersionV6(t *testing.T) { + t.Parallel() + + routerName := fmt.Sprintf("tf-test-router-%s", acctest.RandString(t, 10)) + acctest.VcrTest(t, resource.TestCase{ + PreCheck: func() { acctest.AccTestPreCheck(t) }, + ProtoV5ProviderFactories: acctest.ProtoV5ProviderFactories(t), + CheckDestroy: testAccCheckComputeRouterInterfaceDestroyProducer(t), + Steps: []resource.TestStep{ + { + Config: testAccComputeRouterInterfaceWithIpVersionIPV6(routerName), + Check: testAccCheckComputeRouterInterfaceExists( + t, "google_compute_router_interface.foobar"), + }, + { + ResourceName: "google_compute_router_interface.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccCheckComputeRouterInterfaceDestroyProducer(t *testing.T) func(s *terraform.State) error { return func(s *terraform.State) error { config := acctest.GoogleProviderConfig(t) @@ -513,3 +559,63 @@ resource "google_compute_router_interface" "foobar" { } `, routerName, routerName, routerName, routerName, routerName) } + +func testAccComputeRouterInterfaceWithIpVersionIPV6(routerName string) string { + return fmt.Sprintf(` +resource "google_compute_network" "foobar" { + name = "%s-net" +} + +resource "google_compute_subnetwork" "foobar" { + name = "%s-subnet" + network = google_compute_network.foobar.self_link + ip_cidr_range = "10.0.0.0/16" +} + +resource "google_compute_router" "foobar" { + name = "%s" + network = google_compute_network.foobar.self_link + bgp { + asn = 64514 + } +} + +resource "google_compute_router_interface" "foobar" { + name = "%s-interface" + router = google_compute_router.foobar.name + region = google_compute_router.foobar.region + ip_range = "fdff:1::1:1/126" + ip_version = "IPV6" +} +`, routerName, routerName, routerName, routerName) +} + +func testAccComputeRouterInterfaceWithIpVersionIPV4(routerName string) string { + return fmt.Sprintf(` +resource "google_compute_network" "foobar" { + name = "%s-net" +} + +resource "google_compute_subnetwork" "foobar" { + name = "%s-subnet" + network = google_compute_network.foobar.self_link + ip_cidr_range = "10.0.0.0/16" +} + +resource "google_compute_router" "foobar" { + name = "%s" + network = google_compute_network.foobar.self_link + bgp { + asn = 64514 + } +} + +resource "google_compute_router_interface" "foobar" { + name = "%s-interface" + router = google_compute_router.foobar.name + region = google_compute_router.foobar.region + ip_range = "169.254.3.1/30" + ip_version = "IPV4" +} +`, routerName, routerName, routerName, routerName) +} diff --git a/google/services/compute/resource_compute_router_peer.go b/google/services/compute/resource_compute_router_peer.go index 4720875616a..42ef6ade516 100644 --- a/google/services/compute/resource_compute_router_peer.go +++ b/google/services/compute/resource_compute_router_peer.go @@ -208,6 +208,12 @@ The default is true.`, Description: `Enable IPv6 traffic over BGP Peer. If not specified, it is disabled by default.`, Default: false, }, + "enable_ipv4": { + Type: schema.TypeBool, + Optional: true, + Description: `Enable IPv4 traffic over BGP Peer. It is enabled by default if the peerIpAddress is version 4.`, + Computed: true, + }, "ip_address": { Type: schema.TypeString, Computed: true, @@ -226,6 +232,13 @@ The address must be in the range 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64. If you do not specify the next hop addresses, Google Cloud automatically assigns unused addresses from the 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64 range for you.`, }, + "ipv4_nexthop_address": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ValidateFunc: verify.ValidateIpAddress, + Description: `IPv4 address of the interface inside Google Cloud Platform.`, + }, "peer_ip_address": { Type: schema.TypeString, Computed: true, @@ -244,6 +257,13 @@ The address must be in the range 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64. If you do not specify the next hop addresses, Google Cloud automatically assigns unused addresses from the 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64 range for you.`, }, + "peer_ipv4_nexthop_address": { + Type: schema.TypeString, + Computed: true, + Optional: true, + ValidateFunc: verify.ValidateIpAddress, + Description: `IPv4 address of the BGP interface outside Google Cloud Platform.`, + }, "region": { Type: schema.TypeString, Computed: true, @@ -396,6 +416,24 @@ func resourceComputeRouterBgpPeerCreate(d *schema.ResourceData, meta interface{} } else if v, ok := d.GetOkExists("enable_ipv6"); ok || !reflect.DeepEqual(v, enableIpv6Prop) { obj["enableIpv6"] = enableIpv6Prop } + enableIpv4Prop, err := expandNestedComputeRouterBgpPeerEnableIpv4(d.Get("enable_ipv4"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("enable_ipv4"); ok || !reflect.DeepEqual(v, enableIpv4Prop) { + obj["enableIpv4"] = enableIpv4Prop + } + ipv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv4NexthopAddress(d.Get("ipv4_nexthop_address"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("ipv4_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(ipv4NexthopAddressProp)) && (ok || !reflect.DeepEqual(v, ipv4NexthopAddressProp)) { + obj["ipv4NexthopAddress"] = ipv4NexthopAddressProp + } + peerIpv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(d.Get("peer_ipv4_nexthop_address"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("peer_ipv6_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(peerIpv4NexthopAddressProp)) && (ok || !reflect.DeepEqual(v, peerIpv4NexthopAddressProp)) { + obj["peerIpv4NexthopAddress"] = peerIpv4NexthopAddressProp + } ipv6NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv6NexthopAddress(d.Get("ipv6_nexthop_address"), d, config) if err != nil { return err @@ -587,6 +625,15 @@ func resourceComputeRouterBgpPeerRead(d *schema.ResourceData, meta interface{}) if err := d.Set("enable_ipv6", flattenNestedComputeRouterBgpPeerEnableIpv6(res["enableIpv6"], d, config)); err != nil { return fmt.Errorf("Error reading RouterBgpPeer: %s", err) } + if err := d.Set("enable_ipv4", flattenNestedComputeRouterBgpPeerEnableIpv4(res["enableIpv4"], d, config)); err != nil { + return fmt.Errorf("Error reading RouterBgpPeer: %s", err) + } + if err := d.Set("ipv4_nexthop_address", flattenNestedComputeRouterBgpPeerIpv4NexthopAddress(res["ipv4NexthopAddress"], d, config)); err != nil { + return fmt.Errorf("Error reading RouterBgpPeer: %s", err) + } + if err := d.Set("peer_ipv4_nexthop_address", flattenNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(res["peerIpv4NexthopAddress"], d, config)); err != nil { + return fmt.Errorf("Error reading RouterBgpPeer: %s", err) + } if err := d.Set("ipv6_nexthop_address", flattenNestedComputeRouterBgpPeerIpv6NexthopAddress(res["ipv6NexthopAddress"], d, config)); err != nil { return fmt.Errorf("Error reading RouterBgpPeer: %s", err) } @@ -682,6 +729,24 @@ func resourceComputeRouterBgpPeerUpdate(d *schema.ResourceData, meta interface{} } else if v, ok := d.GetOkExists("enable_ipv6"); ok || !reflect.DeepEqual(v, enableIpv6Prop) { obj["enableIpv6"] = enableIpv6Prop } + enableIpv4Prop, err := expandNestedComputeRouterBgpPeerEnableIpv4(d.Get("enable_ipv4"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("enable_ipv4"); ok || !reflect.DeepEqual(v, enableIpv4Prop) { + obj["enableIpv4"] = enableIpv4Prop + } + ipv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv4NexthopAddress(d.Get("ipv4_nexthop_address"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("ipv4_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(ipv4NexthopAddressProp)) && (ok || !reflect.DeepEqual(v, ipv4NexthopAddressProp)) { + obj["ipv4NexthopAddress"] = ipv4NexthopAddressProp + } + peerIpv4NexthopAddressProp, err := expandNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(d.Get("peer_ipv4_nexthop_address"), d, config) + if err != nil { + return err + } else if v, ok := d.GetOkExists("peer_ipv4_nexthop_address"); !tpgresource.IsEmptyValue(reflect.ValueOf(v)) && (ok || !reflect.DeepEqual(v, peerIpv4NexthopAddressProp)) { + obj["peerIpv4NexthopAddress"] = peerIpv4NexthopAddressProp + } ipv6NexthopAddressProp, err := expandNestedComputeRouterBgpPeerIpv6NexthopAddress(d.Get("ipv6_nexthop_address"), d, config) if err != nil { return err @@ -1055,6 +1120,18 @@ func flattenNestedComputeRouterBgpPeerEnableIpv6(v interface{}, d *schema.Resour return v } +func flattenNestedComputeRouterBgpPeerEnableIpv4(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenNestedComputeRouterBgpPeerIpv4NexthopAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + +func flattenNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { + return v +} + func flattenNestedComputeRouterBgpPeerIpv6NexthopAddress(v interface{}, d *schema.ResourceData, config *transport_tpg.Config) interface{} { return v } @@ -1242,6 +1319,18 @@ func expandNestedComputeRouterBgpPeerEnableIpv6(v interface{}, d tpgresource.Ter return v, nil } +func expandNestedComputeRouterBgpPeerEnableIpv4(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandNestedComputeRouterBgpPeerIpv4NexthopAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + +func expandNestedComputeRouterBgpPeerPeerIpv4NexthopAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { + return v, nil +} + func expandNestedComputeRouterBgpPeerIpv6NexthopAddress(v interface{}, d tpgresource.TerraformResourceData, config *transport_tpg.Config) (interface{}, error) { return v, nil } diff --git a/google/services/compute/resource_compute_router_test.go b/google/services/compute/resource_compute_router_test.go index 49b7de17c12..151b1eab0c2 100644 --- a/google/services/compute/resource_compute_router_test.go +++ b/google/services/compute/resource_compute_router_test.go @@ -157,6 +157,39 @@ func TestAccComputeRouter_updateAddRemoveBGP(t *testing.T) { }) } +func TestAccComputeRouter_addAndUpdateIdentifierRangeBgp(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: testAccComputeRouter_addIdentifierRangeBgp(routerName), + }, + { + ResourceName: "google_compute_router.foobar", + ImportState: true, + ImportStateVerify: true, + }, + { + Config: testAccComputeRouter_updateIdentifierRangeBgp(routerName), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr("google_compute_router.foobar", "bgp.0.identifier_range", "169.254.8.8/30"), + ), + }, + { + ResourceName: "google_compute_router.foobar", + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccComputeRouterBasic(routerName, resourceRegion string) string { return fmt.Sprintf(` resource "google_compute_network" "foobar" { @@ -253,3 +286,57 @@ resource "google_compute_router" "foobar" { } `, routerName, routerName, resourceRegion, routerName) } + +func testAccComputeRouter_addIdentifierRangeBgp(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 = "1.2.3.4" + } + advertised_ip_ranges { + range = "6.7.0.0/16" + } + identifier_range = "169.254.8.8/29" + keepalive_interval = 25 + } +} +`, routerName, routerName) +} + +func testAccComputeRouter_updateIdentifierRangeBgp(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 = "1.2.3.4" + } + advertised_ip_ranges { + range = "6.7.0.0/16" + } + identifier_range = "169.254.8.8/30" + keepalive_interval = 25 + } +} +`, routerName, routerName) +} diff --git a/website/docs/r/compute_router.html.markdown b/website/docs/r/compute_router.html.markdown index 2f4c423662c..4599bfe941c 100644 --- a/website/docs/r/compute_router.html.markdown +++ b/website/docs/r/compute_router.html.markdown @@ -172,7 +172,7 @@ The following arguments are supported: The default is 20. * `identifier_range` - - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) + (Optional) Explicitly specifies a range of valid BGP Identifiers for this Router. It is provided as a link-local IPv4 range (from 169.254.0.0/16), of size at least /30, even if the BGP sessions are over IPv6. It must diff --git a/website/docs/r/compute_router_interface.html.markdown b/website/docs/r/compute_router_interface.html.markdown index 4c884d78088..18a64d96c6d 100644 --- a/website/docs/r/compute_router_interface.html.markdown +++ b/website/docs/r/compute_router_interface.html.markdown @@ -40,7 +40,7 @@ In addition to the above required fields, a router interface must have specified * `ip_range` - (Optional) IP address and range of the interface. The IP range must be in the RFC3927 link-local IP space. Changing this forces a new interface to be created. -* `ip_version` - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) +* `ip_version` - (Optional) IP version of this interface. Can be either IPV4 or IPV6. * `vpn_tunnel` - (Optional) The name or resource link to the VPN tunnel this diff --git a/website/docs/r/compute_router_peer.html.markdown b/website/docs/r/compute_router_peer.html.markdown index 74f0ee69056..805577f5135 100644 --- a/website/docs/r/compute_router_peer.html.markdown +++ b/website/docs/r/compute_router_peer.html.markdown @@ -302,7 +302,7 @@ The following arguments are supported: Enable IPv6 traffic over BGP Peer. If not specified, it is disabled by default. * `enable_ipv4` - - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) + (Optional) Enable IPv4 traffic over BGP Peer. It is enabled by default if the peerIpAddress is version 4. * `ipv6_nexthop_address` - @@ -313,7 +313,7 @@ The following arguments are supported: assigns unused addresses from the 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64 range for you. * `ipv4_nexthop_address` - - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) + (Optional) IPv4 address of the interface inside Google Cloud Platform. * `peer_ipv6_nexthop_address` - @@ -324,7 +324,7 @@ The following arguments are supported: assigns unused addresses from the 2600:2d00:0:2::/64 or 2600:2d00:0:3::/64 range for you. * `peer_ipv4_nexthop_address` - - (Optional, [Beta](https://terraform.io/docs/providers/google/guides/provider_versions.html)) + (Optional) IPv4 address of the BGP interface outside Google Cloud Platform. * `region` -