From 2cc8ed97b56394e0bffa104b34fab30effd7f968 Mon Sep 17 00:00:00 2001 From: Tim Hogarty Date: Fri, 4 Oct 2024 12:48:43 -0700 Subject: [PATCH 1/4] Add BGP Metrics fields for fabric cloud router routing protocols --- equinix/resource_fabric_routing_protocol.go | 80 +++++++++++++++++-- ...source_fabric_routing_protocol_acc_test.go | 15 +++- 2 files changed, 87 insertions(+), 8 deletions(-) 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" } From 2bbb2c113a6defabec9e459306b7b4c8ab6f315f Mon Sep 17 00:00:00 2001 From: Tim Hogarty Date: Fri, 4 Oct 2024 13:17:43 -0700 Subject: [PATCH 2/4] Remove as_override_enabled --- equinix/resource_fabric_routing_protocol.go | 6 ------ equinix/resource_fabric_routing_protocol_acc_test.go | 2 +- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/equinix/resource_fabric_routing_protocol.go b/equinix/resource_fabric_routing_protocol.go index cc7c441da..9a3c3aefd 100644 --- a/equinix/resource_fabric_routing_protocol.go +++ b/equinix/resource_fabric_routing_protocol.go @@ -281,12 +281,6 @@ 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, diff --git a/equinix/resource_fabric_routing_protocol_acc_test.go b/equinix/resource_fabric_routing_protocol_acc_test.go index f62b91e07..e51e4bd01 100644 --- a/equinix/resource_fabric_routing_protocol_acc_test.go +++ b/equinix/resource_fabric_routing_protocol_acc_test.go @@ -150,7 +150,7 @@ resource "equinix_fabric_connection" "this" { } link_protocol { type= "DOT1Q" - vlan_tag= 2008 + vlan_tag= 2009 } location { metro_code = "SV" From 57e9334866c618730408bd920ca7c7dfac2737aa Mon Sep 17 00:00:00 2001 From: Tim Hogarty Date: Fri, 4 Oct 2024 18:43:10 -0700 Subject: [PATCH 3/4] Update outbound_as_prepend_count to string type to account for no given value --- docs/data-sources/fabric_routing_protocol.md | 7 ++ equinix/resource_fabric_routing_protocol.go | 70 +++++++++++++------ ...source_fabric_routing_protocol_acc_test.go | 13 ++-- 3 files changed, 64 insertions(+), 26 deletions(-) diff --git a/docs/data-sources/fabric_routing_protocol.md b/docs/data-sources/fabric_routing_protocol.md index a6a4eff2d..3beb94393 100644 --- a/docs/data-sources/fabric_routing_protocol.md +++ b/docs/data-sources/fabric_routing_protocol.md @@ -79,6 +79,7 @@ output "customer_asn" { ### Read-Only +- `as_override_enabled` (Boolean) Enable AS number override. One of: 0, 1, 3, 5 - `bfd` (Set of Object) Bidirectional Forwarding Detection (see [below for nested schema](#nestedatt--bfd)) - `bgp_auth_key` (String) BGP authorization key - `bgp_ipv4` (Set of Object) Routing Protocol BGP IPv4 (see [below for nested schema](#nestedatt--bgp_ipv4)) @@ -114,6 +115,9 @@ Read-Only: - `customer_peer_ip` (String) - `enabled` (Boolean) - `equinix_peer_ip` (String) +- `inbound_med` (Number) +- `outbound_as_prepend_count` (String) +- `outbound_med` (Number) @@ -124,6 +128,9 @@ Read-Only: - `customer_peer_ip` (String) - `enabled` (Boolean) - `equinix_peer_ip` (String) +- `inbound_med` (Number) +- `outbound_as_prepend_count` (String) +- `outbound_med` (Number) diff --git a/equinix/resource_fabric_routing_protocol.go b/equinix/resource_fabric_routing_protocol.go index 9a3c3aefd..5b6a227fe 100644 --- a/equinix/resource_fabric_routing_protocol.go +++ b/equinix/resource_fabric_routing_protocol.go @@ -62,7 +62,7 @@ func createBgpConnectionIpv4Sch() map[string]*schema.Schema { Description: "Admin status for the BGP session", }, "outbound_as_prepend_count": { - Type: schema.TypeInt, + Type: schema.TypeString, Optional: true, Computed: true, Description: "AS path prepend count", @@ -101,7 +101,7 @@ func createBgpConnectionIpv6Sch() map[string]*schema.Schema { Description: "Admin status for the BGP session", }, "outbound_as_prepend_count": { - Type: schema.TypeInt, + Type: schema.TypeString, Optional: true, Computed: true, Description: "AS path prepend count", @@ -281,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. One of: 0, 1, 3, 5", + }, "bfd": { Type: schema.TypeSet, Optional: true, @@ -356,7 +362,10 @@ func resourceFabricRoutingProtocolCreate(ctx context.Context, d *schema.Resource start := time.Now() type_ := d.Get("type").(string) - createRequest := routingProtocolPayloadFromType(type_, d) + createRequest, err := routingProtocolPayloadFromType(type_, d) + if err != nil { + return diag.Errorf("error creating create request from Terraform configuration values: %s", err) + } fabricRoutingProtocolData, _, err := client.RoutingProtocolsApi.CreateConnectionRoutingProtocol(ctx, d.Get("connection_uuid").(string)).RoutingProtocolBase(createRequest).Execute() @@ -379,7 +388,10 @@ func resourceFabricRoutingProtocolUpdate(ctx context.Context, d *schema.Resource type_ := d.Get("type").(string) - updateRequest := routingProtocolPayloadFromType(type_, d) + updateRequest, err := routingProtocolPayloadFromType(type_, d) + if err != nil { + return diag.Errorf("error creating update request from Terraform configuration values: %s", err) + } start := time.Now() updatedRpResp, _, err := client.RoutingProtocolsApi.ReplaceConnectionRoutingProtocolByUuid(ctx, d.Id(), d.Get("connection_uuid").(string)).RoutingProtocolBase(updateRequest).Execute() @@ -454,7 +466,7 @@ func setIdFromAPIResponse(resp *fabricv4.RoutingProtocolData, isChange bool, d * return changeUuid } -func routingProtocolPayloadFromType(type_ string, d *schema.ResourceData) fabricv4.RoutingProtocolBase { +func routingProtocolPayloadFromType(type_ string, d *schema.ResourceData) (fabricv4.RoutingProtocolBase, error) { payload := fabricv4.RoutingProtocolBase{} if type_ == "BGP" { bgpRP := fabricv4.RoutingProtocolBGPType{} @@ -485,7 +497,10 @@ func routingProtocolPayloadFromType(type_ string, d *schema.ResourceData) fabric schemaBgpIpv4 := d.Get("bgp_ipv4") if schemaBgpIpv4 != nil { - bgpIpv4 := routingProtocolBgpIpv4TerraformToGo(schemaBgpIpv4.(*schema.Set).List()) + bgpIpv4, err := routingProtocolBgpIpv4TerraformToGo(schemaBgpIpv4.(*schema.Set).List()) + if err != nil { + return fabricv4.RoutingProtocolBase{}, err + } if !reflect.DeepEqual(bgpIpv4, fabricv4.BGPConnectionIpv4{}) { bgpRP.SetBgpIpv4(bgpIpv4) } @@ -493,12 +508,18 @@ func routingProtocolPayloadFromType(type_ string, d *schema.ResourceData) fabric schemaBgpIpv6 := d.Get("bgp_ipv6") if schemaBgpIpv6 != nil { - bgpIpv6 := routingProtocolBgpIpv6TerraformToGo(schemaBgpIpv6.(*schema.Set).List()) + bgpIpv6, err := routingProtocolBgpIpv6TerraformToGo(schemaBgpIpv6.(*schema.Set).List()) + if err != nil { + return fabricv4.RoutingProtocolBase{}, err + } if !reflect.DeepEqual(bgpIpv6, fabricv4.BGPConnectionIpv6{}) { bgpRP.SetBgpIpv6(bgpIpv6) } } + asOverrideEnabled := d.Get("as_override_enabled").(bool) + bgpRP.SetAsOverrideEnabled(asOverrideEnabled) + bfdSchema := d.Get("bfd") if bfdSchema != nil { bfd := routingProtocolBfdTerraformToGo(bfdSchema.(*schema.Set).List()) @@ -532,7 +553,7 @@ func routingProtocolPayloadFromType(type_ string, d *schema.ResourceData) fabric } payload = fabricv4.RoutingProtocolDirectTypeAsRoutingProtocolBase(&directRP) } - return payload + return payload, nil } func setFabricRoutingProtocolMap(d *schema.ResourceData, routingProtocolData *fabricv4.RoutingProtocolData) diag.Diagnostics { @@ -556,6 +577,7 @@ func FabricRoutingProtocolMap(routingProtocolData *fabricv4.RoutingProtocolData) routingProtocol["customer_asn"] = rp.GetCustomerAsn() routingProtocol["equinix_asn"] = rp.GetCustomerAsn() routingProtocol["bgp_auth_key"] = rp.GetBgpAuthKey() + routingProtocol["as_override_enabled"] = rp.GetAsOverrideEnabled() if rp.Operation != nil { operation := rp.GetOperation() routingProtocol["operation"] = routingProtocolOperationGoToTerraform(&operation) @@ -734,9 +756,9 @@ func routingProtocolDirectIpv6TerraformToGo(routingProtocolDirectIpv6Request []i return rpDirectIpv6 } -func routingProtocolBgpIpv4TerraformToGo(routingProtocolBgpIpv4Request []interface{}) fabricv4.BGPConnectionIpv4 { +func routingProtocolBgpIpv4TerraformToGo(routingProtocolBgpIpv4Request []interface{}) (fabricv4.BGPConnectionIpv4, error) { if len(routingProtocolBgpIpv4Request) == 0 { - return fabricv4.BGPConnectionIpv4{} + return fabricv4.BGPConnectionIpv4{}, nil } rpBgpIpv4 := fabricv4.BGPConnectionIpv4{} @@ -748,8 +770,12 @@ 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 outboundAsPrependCountStr := bgpIpv4Map["outbound_as_prepend_count"].(string); outboundAsPrependCountStr != "" { + outboundAsPrependCount, err := strconv.ParseInt(outboundAsPrependCountStr, 10, 64) + if err != nil { + return fabricv4.BGPConnectionIpv4{}, fmt.Errorf("error converting outbound_as_prepend_count from string to int64: %s", err) + } + rpBgpIpv4.SetOutboundASPrependCount(outboundAsPrependCount) } if inboundMed := bgpIpv4Map["inbound_med"].(int); inboundMed > 0 { rpBgpIpv4.SetInboundMED(int64(inboundMed)) @@ -758,12 +784,12 @@ func routingProtocolBgpIpv4TerraformToGo(routingProtocolBgpIpv4Request []interfa rpBgpIpv4.SetOutboundMED(int64(outboundMed)) } - return rpBgpIpv4 + return rpBgpIpv4, nil } -func routingProtocolBgpIpv6TerraformToGo(routingProtocolBgpIpv6Request []interface{}) fabricv4.BGPConnectionIpv6 { +func routingProtocolBgpIpv6TerraformToGo(routingProtocolBgpIpv6Request []interface{}) (fabricv4.BGPConnectionIpv6, error) { if len(routingProtocolBgpIpv6Request) == 0 { - return fabricv4.BGPConnectionIpv6{} + return fabricv4.BGPConnectionIpv6{}, nil } rpBgpIpv6 := fabricv4.BGPConnectionIpv6{} @@ -775,8 +801,12 @@ 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 outboundAsPrependCountStr := bgpIpv6Map["outbound_as_prepend_count"].(string); outboundAsPrependCountStr != "" { + outboundAsPrependCount, err := strconv.ParseInt(outboundAsPrependCountStr, 10, 64) + if err != nil { + return fabricv4.BGPConnectionIpv6{}, err + } + rpBgpIpv6.SetOutboundASPrependCount(outboundAsPrependCount) } if inboundMed := bgpIpv6Map["inbound_med"].(int); inboundMed > 0 { rpBgpIpv6.SetInboundMED(int64(inboundMed)) @@ -785,7 +815,7 @@ func routingProtocolBgpIpv6TerraformToGo(routingProtocolBgpIpv6Request []interfa rpBgpIpv6.SetOutboundMED(int64(outboundMed)) } - return rpBgpIpv6 + return rpBgpIpv6, nil } func routingProtocolBfdTerraformToGo(routingProtocolBfdRequest []interface{}) fabricv4.RoutingProtocolBFD { @@ -846,7 +876,7 @@ func routingProtocolBgpConnectionIpv4GoToTerraform(routingProtocolBgpIpv4 *fabri "customer_peer_ip": routingProtocolBgpIpv4.GetCustomerPeerIp(), "equinix_peer_ip": routingProtocolBgpIpv4.GetEquinixPeerIp(), "enabled": routingProtocolBgpIpv4.GetEnabled(), - "outbound_as_prepend_count": int(routingProtocolBgpIpv4.GetOutboundASPrependCount()), + "outbound_as_prepend_count": strconv.FormatInt(routingProtocolBgpIpv4.GetOutboundASPrependCount(), 10), "inbound_med": int(routingProtocolBgpIpv4.GetInboundMED()), "outbound_med": int(routingProtocolBgpIpv4.GetOutboundMED()), } @@ -866,7 +896,7 @@ func routingProtocolBgpConnectionIpv6GoToTerraform(routingProtocolBgpIpv6 *fabri "customer_peer_ip": routingProtocolBgpIpv6.GetCustomerPeerIp(), "equinix_peer_ip": routingProtocolBgpIpv6.GetEquinixPeerIp(), "enabled": routingProtocolBgpIpv6.GetEnabled(), - "outbound_as_prepend_count": int(routingProtocolBgpIpv6.GetOutboundASPrependCount()), + "outbound_as_prepend_count": strconv.FormatInt(routingProtocolBgpIpv6.GetOutboundASPrependCount(), 10), "inbound_med": int(routingProtocolBgpIpv6.GetInboundMED()), "outbound_med": int(routingProtocolBgpIpv6.GetOutboundMED()), } diff --git a/equinix/resource_fabric_routing_protocol_acc_test.go b/equinix/resource_fabric_routing_protocol_acc_test.go index e51e4bd01..bd9103bc0 100644 --- a/equinix/resource_fabric_routing_protocol_acc_test.go +++ b/equinix/resource_fabric_routing_protocol_acc_test.go @@ -3,13 +3,14 @@ package equinix_test import ( "context" "fmt" - "github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "testing" "time" "github.com/equinix/terraform-provider-equinix/equinix" "github.com/equinix/terraform-provider-equinix/internal/acceptance" + "github.com/equinix/terraform-provider-equinix/internal/fabric/testing_helpers" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/hashicorp/terraform-plugin-testing/helper/resource" "github.com/hashicorp/terraform-plugin-testing/terraform" ) @@ -150,7 +151,7 @@ resource "equinix_fabric_connection" "this" { } link_protocol { type= "DOT1Q" - vlan_tag= 2009 + vlan_tag= 2011 } location { metro_code = "SV" @@ -180,17 +181,17 @@ resource "equinix_fabric_routing_protocol" "bgp" { name = "rp_bgp_PFCR" bgp_ipv4{ customer_peer_ip = "190.1.1.2" - outbound_as_prepend_count = 1 + outbound_as_prepend_count = "1" inbound_med = 4 outbound_med = 7 } bgp_ipv6{ customer_peer_ip = "190::1:2" - outbound_as_prepend_count = 1 + outbound_as_prepend_count = "1" inbound_med = 4 outbound_med = 7 } - customer_asn = "100" + customer_asn = 100 } data "equinix_fabric_routing_protocol" "direct" { From da1917847324e3cbc575a514a71cc23ebe16851b Mon Sep 17 00:00:00 2001 From: Tim Hogarty Date: Fri, 4 Oct 2024 20:20:34 -0700 Subject: [PATCH 4/4] Fix errors in docs for routing protocol --- docs/data-sources/fabric_routing_protocol.md | 2 +- docs/resources/fabric_routing_protocol.md | 27 +-- equinix/resource_fabric_routing_protocol.go | 6 +- .../resources/fabric_routing_protocol.md.tmpl | 163 +----------------- 4 files changed, 20 insertions(+), 178 deletions(-) diff --git a/docs/data-sources/fabric_routing_protocol.md b/docs/data-sources/fabric_routing_protocol.md index 3beb94393..023db024f 100644 --- a/docs/data-sources/fabric_routing_protocol.md +++ b/docs/data-sources/fabric_routing_protocol.md @@ -79,7 +79,7 @@ output "customer_asn" { ### Read-Only -- `as_override_enabled` (Boolean) Enable AS number override. One of: 0, 1, 3, 5 +- `as_override_enabled` (Boolean) Enable AS number override - `bfd` (Set of Object) Bidirectional Forwarding Detection (see [below for nested schema](#nestedatt--bfd)) - `bgp_auth_key` (String) BGP authorization key - `bgp_ipv4` (Set of Object) Routing Protocol BGP IPv4 (see [below for nested schema](#nestedatt--bgp_ipv4)) diff --git a/docs/resources/fabric_routing_protocol.md b/docs/resources/fabric_routing_protocol.md index 74d054a6f..e56d2fb0f 100644 --- a/docs/resources/fabric_routing_protocol.md +++ b/docs/resources/fabric_routing_protocol.md @@ -86,7 +86,6 @@ resource "equinix_fabric_routing_protocol" "bgp" { ``` - ## Schema ### Required @@ -95,6 +94,7 @@ resource "equinix_fabric_routing_protocol" "bgp" { ### Optional +- `as_override_enabled` (Boolean) Enable AS number override - `bfd` (Block Set) Bidirectional Forwarding Detection (see [below for nested schema](#nestedblock--bfd)) - `bgp_auth_key` (String) BGP authorization key - `bgp_ipv4` (Block Set) Routing Protocol BGP IPv4 (see [below for nested schema](#nestedblock--bgp_ipv4)) @@ -119,7 +119,6 @@ resource "equinix_fabric_routing_protocol" "bgp" { - `state` (String) Routing Protocol overall state - ### Nested Schema for `bfd` Required: @@ -130,8 +129,8 @@ Optional: - `interval` (String) Interval range between the received BFD control packets - + ### Nested Schema for `bgp_ipv4` Required: @@ -141,13 +140,16 @@ Required: Optional: - `enabled` (Boolean) Admin status for the BGP session +- `inbound_med` (Number) Inbound Multi Exit Discriminator attribute +- `outbound_as_prepend_count` (String) AS path prepend count. One of: 0, 1, 3, 5 +- `outbound_med` (Number) Outbound Multi Exit Discriminator attribute Read-Only: - `equinix_peer_ip` (String) Equinix side peering ip - + ### Nested Schema for `bgp_ipv6` Required: @@ -157,29 +159,32 @@ Required: Optional: - `enabled` (Boolean) Admin status for the BGP session +- `inbound_med` (Number) Inbound Multi Exit Discriminator attribute +- `outbound_as_prepend_count` (String) AS path prepend count. One of: 0, 1, 3, 5 +- `outbound_med` (Number) Outbound Multi Exit Discriminator attribute Read-Only: - `equinix_peer_ip` (String) Equinix side peering ip - + ### Nested Schema for `direct_ipv4` Required: - `equinix_iface_ip` (String) Equinix side Interface IP address - + ### Nested Schema for `direct_ipv6` Optional: - `equinix_iface_ip` (String) Equinix side Interface IP address - + ### Nested Schema for `timeouts` Optional: @@ -189,8 +194,8 @@ Optional: - `read` (String) - `update` (String) - + ### Nested Schema for `change` Read-Only: @@ -199,8 +204,8 @@ Read-Only: - `type` (String) - `uuid` (String) - + ### Nested Schema for `change_log` Read-Only: @@ -218,8 +223,8 @@ Read-Only: - `updated_by_full_name` (String) - `updated_date_time` (String) - + ### Nested Schema for `operation` Read-Only: @@ -227,7 +232,6 @@ Read-Only: - `errors` (List of Object) (see [below for nested schema](#nestedobjatt--operation--errors)) - ### Nested Schema for `operation.errors` Read-Only: @@ -240,7 +244,6 @@ Read-Only: - `help` (String) - ### Nested Schema for `operation.errors.additional_info` Read-Only: diff --git a/equinix/resource_fabric_routing_protocol.go b/equinix/resource_fabric_routing_protocol.go index 5b6a227fe..08b0ea36c 100644 --- a/equinix/resource_fabric_routing_protocol.go +++ b/equinix/resource_fabric_routing_protocol.go @@ -65,7 +65,7 @@ func createBgpConnectionIpv4Sch() map[string]*schema.Schema { Type: schema.TypeString, Optional: true, Computed: true, - Description: "AS path prepend count", + Description: "AS path prepend count. One of: 0, 1, 3, 5", }, "inbound_med": { Type: schema.TypeInt, @@ -104,7 +104,7 @@ func createBgpConnectionIpv6Sch() map[string]*schema.Schema { Type: schema.TypeString, Optional: true, Computed: true, - Description: "AS path prepend count", + Description: "AS path prepend count. One of: 0, 1, 3, 5", }, "inbound_med": { Type: schema.TypeInt, @@ -285,7 +285,7 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Type: schema.TypeBool, Optional: true, Computed: true, - Description: "Enable AS number override. One of: 0, 1, 3, 5", + Description: "Enable AS number override", }, "bfd": { Type: schema.TypeSet, diff --git a/templates/resources/fabric_routing_protocol.md.tmpl b/templates/resources/fabric_routing_protocol.md.tmpl index f8ce5a7c8..128b202b6 100644 --- a/templates/resources/fabric_routing_protocol.md.tmpl +++ b/templates/resources/fabric_routing_protocol.md.tmpl @@ -32,165 +32,4 @@ Direct and BGP Routing Protocol (Requires Depends On to Handle Synchronization): {{tffile "examples/resources/equinix_fabric_routing_protocol/example_3.tf"}} - - -## Schema - -### Required - -- `connection_uuid` (String) Connection URI associated with Routing Protocol - -### Optional - -- `bfd` (Block Set) Bidirectional Forwarding Detection (see [below for nested schema](#nestedblock--bfd)) -- `bgp_auth_key` (String) BGP authorization key -- `bgp_ipv4` (Block Set) Routing Protocol BGP IPv4 (see [below for nested schema](#nestedblock--bgp_ipv4)) -- `bgp_ipv6` (Block Set) Routing Protocol BGP IPv6 (see [below for nested schema](#nestedblock--bgp_ipv6)) -- `customer_asn` (Number) Customer-provided ASN -- `description` (String) Customer-provided Fabric Routing Protocol description -- `direct_ipv4` (Block Set) Routing Protocol Direct IPv4 (see [below for nested schema](#nestedblock--direct_ipv4)) -- `direct_ipv6` (Block Set) Routing Protocol Direct IPv6 (see [below for nested schema](#nestedblock--direct_ipv6)) -- `name` (String) Routing Protocol name. An alpha-numeric 24 characters string which can include only hyphens and underscores -- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) -- `type` (String) Defines the routing protocol type like BGP or DIRECT -- `uuid` (String) Equinix-assigned routing protocol identifier - -### Read-Only - -- `change` (Set of Object) Routing Protocol configuration Changes (see [below for nested schema](#nestedatt--change)) -- `change_log` (Set of Object) Captures Routing Protocol lifecycle change information (see [below for nested schema](#nestedatt--change_log)) -- `equinix_asn` (Number) Equinix ASN -- `href` (String) Routing Protocol URI information -- `id` (String) The ID of this resource. -- `operation` (Set of Object) Routing Protocol type-specific operational data (see [below for nested schema](#nestedatt--operation)) -- `state` (String) Routing Protocol overall state - - - -### Nested Schema for `bfd` - -Required: - -- `enabled` (Boolean) Bidirectional Forwarding Detection enablement - -Optional: - -- `interval` (String) Interval range between the received BFD control packets - - - -### Nested Schema for `bgp_ipv4` - -Required: - -- `customer_peer_ip` (String) Customer side peering ip - -Optional: - -- `enabled` (Boolean) Admin status for the BGP session - -Read-Only: - -- `equinix_peer_ip` (String) Equinix side peering ip - - - -### Nested Schema for `bgp_ipv6` - -Required: - -- `customer_peer_ip` (String) Customer side peering ip - -Optional: - -- `enabled` (Boolean) Admin status for the BGP session - -Read-Only: - -- `equinix_peer_ip` (String) Equinix side peering ip - - - -### Nested Schema for `direct_ipv4` - -Required: - -- `equinix_iface_ip` (String) Equinix side Interface IP address - - - -### Nested Schema for `direct_ipv6` - -Optional: - -- `equinix_iface_ip` (String) Equinix side Interface IP address - - - -### Nested Schema for `timeouts` - -Optional: - -- `create` (String) -- `delete` (String) -- `read` (String) -- `update` (String) - - - -### Nested Schema for `change` - -Read-Only: - -- `href` (String) -- `type` (String) -- `uuid` (String) - - - -### Nested Schema for `change_log` - -Read-Only: - -- `created_by` (String) -- `created_by_email` (String) -- `created_by_full_name` (String) -- `created_date_time` (String) -- `deleted_by` (String) -- `deleted_by_email` (String) -- `deleted_by_full_name` (String) -- `deleted_date_time` (String) -- `updated_by` (String) -- `updated_by_email` (String) -- `updated_by_full_name` (String) -- `updated_date_time` (String) - - - -### Nested Schema for `operation` - -Read-Only: - -- `errors` (List of Object) (see [below for nested schema](#nestedobjatt--operation--errors)) - - - -### Nested Schema for `operation.errors` - -Read-Only: - -- `additional_info` (List of Object) (see [below for nested schema](#nestedobjatt--operation--errors--additional_info)) -- `correlation_id` (String) -- `details` (String) -- `error_code` (String) -- `error_message` (String) -- `help` (String) - - - -### Nested Schema for `operation.errors.additional_info` - -Read-Only: - -- `property` (String) -- `reason` (String) +{{ .SchemaMarkdown | trimspace }}