diff --git a/equinix/resource_fabric_routing_protocol.go b/equinix/resource_fabric_routing_protocol.go index 1f286110c..cc7c441da 100644 --- a/equinix/resource_fabric_routing_protocol.go +++ b/equinix/resource_fabric_routing_protocol.go @@ -61,6 +61,24 @@ func createBgpConnectionIpv4Sch() map[string]*schema.Schema { Default: true, Description: "Admin status for the BGP session", }, + "outbound_as_prepend_count": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AS path prepend count", + }, + "inbound_med": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Inbound Multi Exit Discriminator attribute", + }, + "outbound_med": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Outbound Multi Exit Discriminator attribute", + }, } } @@ -82,6 +100,24 @@ func createBgpConnectionIpv6Sch() map[string]*schema.Schema { Default: true, Description: "Admin status for the BGP session", }, + "outbound_as_prepend_count": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "AS path prepend count", + }, + "inbound_med": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Inbound Multi Exit Discriminator attribute", + }, + "outbound_med": { + Type: schema.TypeInt, + Optional: true, + Computed: true, + Description: "Outbound Multi Exit Discriminator attribute", + }, } } @@ -245,6 +281,12 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Computed: true, Description: "BGP authorization key", }, + "as_override_enabled": { + Type: schema.TypeBool, + Optional: true, + Computed: true, + Description: "Enable AS number override", + }, "bfd": { Type: schema.TypeSet, Optional: true, @@ -712,6 +754,16 @@ func routingProtocolBgpIpv4TerraformToGo(routingProtocolBgpIpv4Request []interfa enabled := bgpIpv4Map["enabled"].(bool) rpBgpIpv4.SetEnabled(enabled) + if outboundAsPrependCount := bgpIpv4Map["outbound_as_prepend_count"].(int); outboundAsPrependCount > 0 { + rpBgpIpv4.SetOutboundASPrependCount(int64(outboundAsPrependCount)) + } + if inboundMed := bgpIpv4Map["inbound_med"].(int); inboundMed > 0 { + rpBgpIpv4.SetInboundMED(int64(inboundMed)) + } + if outboundMed := bgpIpv4Map["outbound_med"].(int); outboundMed > 0 { + rpBgpIpv4.SetOutboundMED(int64(outboundMed)) + } + return rpBgpIpv4 } @@ -729,6 +781,16 @@ func routingProtocolBgpIpv6TerraformToGo(routingProtocolBgpIpv6Request []interfa enabled := bgpIpv6Map["enabled"].(bool) rpBgpIpv6.SetEnabled(enabled) + if outboundAsPrependCount := bgpIpv6Map["outbound_as_prepend_count"].(int); outboundAsPrependCount > 0 { + rpBgpIpv6.SetOutboundASPrependCount(int64(outboundAsPrependCount)) + } + if inboundMed := bgpIpv6Map["inbound_med"].(int); inboundMed > 0 { + rpBgpIpv6.SetInboundMED(int64(inboundMed)) + } + if outboundMed := bgpIpv6Map["outbound_med"].(int); outboundMed > 0 { + rpBgpIpv6.SetOutboundMED(int64(outboundMed)) + } + return rpBgpIpv6 } @@ -787,9 +849,12 @@ func routingProtocolBgpConnectionIpv4GoToTerraform(routingProtocolBgpIpv4 *fabri } mappedBgpIpv4 := map[string]interface{}{ - "customer_peer_ip": routingProtocolBgpIpv4.GetCustomerPeerIp(), - "equinix_peer_ip": routingProtocolBgpIpv4.GetEquinixPeerIp(), - "enabled": routingProtocolBgpIpv4.GetEnabled(), + "customer_peer_ip": routingProtocolBgpIpv4.GetCustomerPeerIp(), + "equinix_peer_ip": routingProtocolBgpIpv4.GetEquinixPeerIp(), + "enabled": routingProtocolBgpIpv4.GetEnabled(), + "outbound_as_prepend_count": int(routingProtocolBgpIpv4.GetOutboundASPrependCount()), + "inbound_med": int(routingProtocolBgpIpv4.GetInboundMED()), + "outbound_med": int(routingProtocolBgpIpv4.GetOutboundMED()), } rpBgpIpv4Set := schema.NewSet( schema.HashResource(&schema.Resource{Schema: createBgpConnectionIpv4Sch()}), @@ -804,9 +869,12 @@ func routingProtocolBgpConnectionIpv6GoToTerraform(routingProtocolBgpIpv6 *fabri } mappedBgpIpv6 := map[string]interface{}{ - "customer_peer_ip": routingProtocolBgpIpv6.GetCustomerPeerIp(), - "equinix_peer_ip": routingProtocolBgpIpv6.GetEquinixPeerIp(), - "enabled": routingProtocolBgpIpv6.GetEnabled(), + "customer_peer_ip": routingProtocolBgpIpv6.GetCustomerPeerIp(), + "equinix_peer_ip": routingProtocolBgpIpv6.GetEquinixPeerIp(), + "enabled": routingProtocolBgpIpv6.GetEnabled(), + "outbound_as_prepend_count": int(routingProtocolBgpIpv6.GetOutboundASPrependCount()), + "inbound_med": int(routingProtocolBgpIpv6.GetInboundMED()), + "outbound_med": int(routingProtocolBgpIpv6.GetOutboundMED()), } rpBgpIpv6Set := schema.NewSet( diff --git a/equinix/resource_fabric_routing_protocol_acc_test.go b/equinix/resource_fabric_routing_protocol_acc_test.go index d8ad6aec5..f62b91e07 100644 --- a/equinix/resource_fabric_routing_protocol_acc_test.go +++ b/equinix/resource_fabric_routing_protocol_acc_test.go @@ -53,9 +53,15 @@ func TestAccFabricCreateRoutingProtocols_PFCR(t *testing.T) { resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv4.0.customer_peer_ip", "190.1.1.2"), resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv4.0.equinix_peer_ip", "190.1.1.1"), resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv4.0.enabled", "true"), + resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv4.0.outbound_as_prepend_count", "1"), + resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv4.0.inbound_med", "4"), + resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv4.0.outbound_med", "7"), resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv6.0.customer_peer_ip", "190::1:2"), resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv6.0.equinix_peer_ip", "190::1:1"), resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv6.0.enabled", "true"), + resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv6.0.outbound_as_prepend_count", "1"), + resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv6.0.inbound_med", "4"), + resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "bgp_ipv6.0.outbound_med", "7"), resource.TestCheckResourceAttr("equinix_fabric_routing_protocol.bgp", "customer_asn", "100"), resource.TestCheckResourceAttrSet("data.equinix_fabric_routing_protocol.direct", "id"), @@ -79,7 +85,6 @@ func TestAccFabricCreateRoutingProtocols_PFCR(t *testing.T) { resource.TestCheckResourceAttr("data.equinix_fabric_routing_protocol.bgp", "bgp_ipv6.0.enabled", "true"), resource.TestCheckResourceAttr("data.equinix_fabric_routing_protocol.bgp", "customer_asn", "100"), ), - ExpectNonEmptyPlan: true, }, }, }) @@ -145,7 +150,7 @@ resource "equinix_fabric_connection" "this" { } link_protocol { type= "DOT1Q" - vlan_tag= 2152 + vlan_tag= 2008 } location { metro_code = "SV" @@ -175,9 +180,15 @@ resource "equinix_fabric_routing_protocol" "bgp" { name = "rp_bgp_PFCR" bgp_ipv4{ customer_peer_ip = "190.1.1.2" + outbound_as_prepend_count = 1 + inbound_med = 4 + outbound_med = 7 } bgp_ipv6{ customer_peer_ip = "190::1:2" + outbound_as_prepend_count = 1 + inbound_med = 4 + outbound_med = 7 } customer_asn = "100" }