From e616be3925151c8b0f2d6c42b0fae7ead5285a69 Mon Sep 17 00:00:00 2001 From: Oscar Cobles Date: Thu, 14 Jul 2022 06:26:12 -0500 Subject: [PATCH 1/6] update go to point to ecx-go branch WIP --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 84447b77f..10eb8826e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/equinix/terraform-provider-equinix go 1.17 require ( - github.com/equinix/ecx-go/v2 v2.2.0 + github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095 github.com/equinix/ne-go v1.6.0 github.com/equinix/oauth2-go v1.0.0 github.com/equinix/rest-go v1.3.0 diff --git a/go.sum b/go.sum index ddf68149d..f25db37d8 100644 --- a/go.sum +++ b/go.sum @@ -97,8 +97,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/equinix/ecx-go/v2 v2.2.0 h1:8aFOVUVsN4923w+OGY9m7KnfcgMkaIKAQzryS+P9iAY= -github.com/equinix/ecx-go/v2 v2.2.0/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= +github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095 h1:Hzncnz4Ni3ZF3doZR2bgVgq5QyB3AEmA9scykqPiBlk= +github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= github.com/equinix/ne-go v1.6.0 h1:jp95igkZoMi161wycIIzvQiW2Vyh2Uy5GnOICZ7CjSQ= github.com/equinix/ne-go v1.6.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI= github.com/equinix/oauth2-go v1.0.0 h1:fHtAPGq82PdgtK5vEThs8Vwz6f7D/8SX4tE3NJu+KcU= From 7f246731ed2c3f140788965ca30ce366f080b5a6 Mon Sep 17 00:00:00 2001 From: Oscar Cobles Date: Thu, 14 Jul 2022 09:12:29 -0500 Subject: [PATCH 2/6] support for zside_service_token attribute --- equinix/resource_ecx_l2_connection.go | 28 +- .../resource_ecx_l2_connection_acc_test.go | 245 ++++++++++++++---- equinix/resource_ecx_l2_connection_test.go | 2 + 3 files changed, 217 insertions(+), 58 deletions(-) diff --git a/equinix/resource_ecx_l2_connection.go b/equinix/resource_ecx_l2_connection.go index 4b05a4680..bbd589656 100644 --- a/equinix/resource_ecx_l2_connection.go +++ b/equinix/resource_ecx_l2_connection.go @@ -33,6 +33,7 @@ var ecxL2ConnectionSchemaNames = map[string]string{ "NamedTag": "named_tag", "AdditionalInfo": "additional_info", "ZSidePortUUID": "zside_port_uuid", + "ZSideServiceToken": "zside_service_token", "ZSideVlanSTag": "zside_vlan_stag", "ZSideVlanCTag": "zside_vlan_ctag", "SellerRegion": "seller_region", @@ -64,6 +65,7 @@ var ecxL2ConnectionDescriptions = map[string]string{ "NamedTag": "The type of peering to set up in case when connecting to Azure Express Route. One of PRIVATE, MICROSOFT, MANUAL, PUBLIC (MANUAL and PUBLIC are deprecated and not available for new connections)", "AdditionalInfo": "One or more additional information key-value objects", "ZSidePortUUID": "Unique identifier of the port on the remote side (z-side)", + "ZSideServiceToken": "Unique Equinix Fabric key given by a provider that grants you authorization to enable connectivity to a shared multi-tenant port (z-side)", "ZSideVlanSTag": "S-Tag/Outer-Tag of the connection on the remote side (z-side)", "ZSideVlanCTag": "C-Tag/Inner-Tag of the connection on the remote side (z-side)", "SellerRegion": "The region in which the seller port resides", @@ -166,7 +168,11 @@ func createECXL2ConnectionResourceSchema() map[string]*schema.Schema { Optional: true, Computed: true, ForceNew: true, - AtLeastOneOf: []string{ecxL2ConnectionSchemaNames["ProfileUUID"], ecxL2ConnectionSchemaNames["ZSidePortUUID"]}, + AtLeastOneOf: []string{ + ecxL2ConnectionSchemaNames["ProfileUUID"], + ecxL2ConnectionSchemaNames["ZSidePortUUID"], + ecxL2ConnectionSchemaNames["ZSideServiceToken"], + }, ValidateFunc: validation.StringIsNotEmpty, Description: ecxL2ConnectionDescriptions["ProfileUUID"], }, @@ -365,6 +371,20 @@ func createECXL2ConnectionResourceSchema() map[string]*schema.Schema { ConflictsWith: []string{ecxL2ConnectionSchemaNames["PortUUID"], ecxL2ConnectionSchemaNames["DeviceUUID"]}, Description: ecxL2ConnectionDescriptions["ServiceToken"], }, + ecxL2ConnectionSchemaNames["ZSideServiceToken"]: { + Type: schema.TypeString, + Optional: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + ConflictsWith: []string{ + ecxL2ConnectionSchemaNames["ServiceToken"], + ecxL2ConnectionSchemaNames["ProfileUUID"], + ecxL2ConnectionSchemaNames["ZSidePortUUID"], + ecxL2ConnectionSchemaNames["AuthorizationKey"], + ecxL2ConnectionSchemaNames["SecondaryConnection"], + }, + Description: ecxL2ConnectionDescriptions["ZSideServiceToken"], + }, } } @@ -828,6 +848,9 @@ func createECXL2Connections(d *schema.ResourceData) (*ecx.L2Connection, *ecx.L2C if v, ok := d.GetOk(ecxL2ConnectionSchemaNames["ServiceToken"]); ok { primary.ServiceToken = ecx.String(v.(string)) } + if v, ok := d.GetOk(ecxL2ConnectionSchemaNames["ZSideServiceToken"]); ok { + primary.ZSideServiceToken = ecx.String(v.(string)) + } if v, ok := d.GetOk(ecxL2ConnectionSchemaNames["AuthorizationKey"]); ok { primary.AuthorizationKey = ecx.String(v.(string)) } @@ -910,6 +933,9 @@ func updateECXL2ConnectionResource(primary *ecx.L2Connection, secondary *ecx.L2C if err := d.Set(ecxL2ConnectionSchemaNames["ServiceToken"], primary.ServiceToken); err != nil { return fmt.Errorf("error reading ServiceToken: %s", err) } + if err := d.Set(ecxL2ConnectionSchemaNames["ZSideServiceToken"], primary.ZSideServiceToken); err != nil { + return fmt.Errorf("error reading ZSideServiceToken: %s", err) + } if err := d.Set(ecxL2ConnectionSchemaNames["Actions"], flattenECXL2ConnectionActions(primary.Actions)); err != nil { return fmt.Errorf("error reading Actions: %s", err) } diff --git a/equinix/resource_ecx_l2_connection_acc_test.go b/equinix/resource_ecx_l2_connection_acc_test.go index 2203d7a34..6889c6a1d 100644 --- a/equinix/resource_ecx_l2_connection_acc_test.go +++ b/equinix/resource_ecx_l2_connection_acc_test.go @@ -416,6 +416,122 @@ func TestAccFabricL2Connection_ServiceToken_HA_SP(t *testing.T) { }) } +func TestAccFabricL2Connection_ZSideServiceToken_Single(t *testing.T) { + priZSideServiceToken := "d63247a3-0a64-6cab-c310-e1f5d8ac43a4" + priZSidePortUUID := "8e2147a3-38ec-470e-48c9-e1f5d81c3bb0" + priServiceToken := "624447a3-4cb2-470e-93c5-f155d81c3bb0" + priConnID := "4b95a8df-8d26-4c4b-a64d-18ac43a43248" + priPortUUID := "52c00d7f-c310-458e-9426-1d7549e1f600" + priConnName := fmt.Sprintf("%s-%s", tstResourcePrefix, "st-pri") + secServiceToken := "1c356a7b-d632-18a5-c357-a33146cab65d" + secConnName := fmt.Sprintf("%s-%s", tstResourcePrefix, "st-sec") + authKey := "123456789012" + speed := 50 + speedUnit := "MB" + notifications := []string{"marry@equinix.com", "john@equinix.com"} + sellerMetro := "SV" + sellerProfileUUID := "5d113752-996b-4b59-8e21-8927e7b98058" + redundancyGroupUUID := "db760d63-38ec-49c2-bebf-b3ac3c33df77" + redundancyType := "SECONDARY" + + ctx := map[string]interface{}{ + "connection-resourceName": "test", + "connection-profile_uuid": sellerProfileUUID, + "connection-name": priConnName, + "connection-speed": speed, + "connection-speed_unit": speedUnit, + "connection-notifications": notifications, + "connection-seller_metro_code": sellerMetro, + "connection-authorization_key": authKey, + "zside-service_token": priZSideServiceToken, + "zside-port_uuid": priZSidePortUUID, + "service_token": priServiceToken, + "port-uuid": priPortUUID, + "connection-secondary_name": secConnName, + "secondary-service_token": secServiceToken, + } + + ctxWithoutConflicts := copyMap(ctx) + delete(ctxWithoutConflicts, "service_token") + delete(ctxWithoutConflicts, "zside-port_uuid") + delete(ctxWithoutConflicts, "connection-profile_uuid") + delete(ctxWithoutConflicts, "connection-authorization_key") + delete(ctxWithoutConflicts, "connection-secondary_name") + delete(ctxWithoutConflicts, "secondary-service_token") + + // mock ECX Client functions + mockECXClient := &mockECXClient{ + CreateL2ConnectionFn: func(primConn ecx.L2Connection) (*string, error) { + return &priConnID, nil + }, + GetL2ConnectionFn: func(uuid string) (*ecx.L2Connection, error) { + status := ecx.ConnectionStatusProvisioned + connection := ecx.L2Connection{ + Speed: &speed, + SpeedUnit: &speedUnit, + Notifications: notifications, + ProfileUUID: &sellerProfileUUID, + Status: &status, + AuthorizationKey: &authKey, + SellerMetroCode: &sellerMetro, + RedundancyGroup: &redundancyGroupUUID, + RedundancyType: &redundancyType, + UUID: &priConnID, + Name: &priConnName, + ZSideServiceToken: &priZSideServiceToken, + PortUUID: &priPortUUID, + ZSidePortUUID: &priZSidePortUUID, + } + return &connection, nil + }, + DeleteL2ConnectionFn: func(uuid string) error { + err := rest.Error{} + err.ApplicationErrors = []rest.ApplicationError{ + { + Code: "IC-LAYER2-4021", + }, + } + return err + }, + } + mockEquinix := Provider() + mockEquinix.ConfigureContextFunc = func(c context.Context, d *schema.ResourceData) (interface{}, diag.Diagnostics) { + config := Config{ + ecx: mockECXClient, + } + return &config, nil + } + mockProviders := map[string]*schema.Provider{ + "equinix": mockEquinix, + } + + resourceName := fmt.Sprintf("equinix_ecx_l2_connection.%s", ctx["connection-resourceName"].(string)) + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: mockProviders, + PreventPostDestroyRefresh: true, + Steps: []resource.TestStep{ + { + Config: newTestAccConfig(ctx).withConnection().build(), + ExpectError: regexp.MustCompile(`Error: Conflicting configuration arguments`), + }, + { + Config: newTestAccConfig(ctxWithoutConflicts).withConnection().build(), + Check: resource.ComposeTestCheckFunc( + resource.TestCheckResourceAttr(resourceName, "status", ecx.ConnectionStatusProvisioned), + resource.TestCheckResourceAttrSet(resourceName, "zside_service_token"), + resource.TestCheckResourceAttrSet(resourceName, "port_uuid"), + ), + }, + { + ResourceName: resourceName, + ImportState: true, + ImportStateVerify: true, + }, + }, + }) +} + func testAccFabricL2ConnectionExists(resourceName string, conn *ecx.L2Connection) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[resourceName] @@ -585,11 +701,13 @@ data "equinix_ecx_port" "%{port-secondary_resourceName}" { func testAccFabricL2Connection(ctx map[string]interface{}) string { var config string - if _, ok := ctx["connection-profile_uuid"]; !ok { - config += nprintf(` + if _, ok := ctx["zside-service_token"]; !ok { + if _, ok := ctx["connection-profile_uuid"]; !ok { + config += nprintf(` data "equinix_ecx_l2_sellerprofile" "pri" { name = "%{connection-profile_name}" }`, ctx) + } } if _, ok := ctx["connection-secondary_profile_name"]; ok { config += nprintf(` @@ -604,113 +722,126 @@ resource "equinix_ecx_l2_connection" "%{connection-resourceName}" { speed = %{connection-speed} speed_unit = "%{connection-speed_unit}" notifications = %{connection-notifications} - seller_metro_code = "%{connection-seller_metro_code}" - authorization_key = "%{connection-authorization_key}"`, ctx) - if _, ok := ctx["connection-profile_uuid"]; ok { + seller_metro_code = "%{connection-seller_metro_code}"`, ctx) + if _, ok := ctx["connection-authorization_key"]; ok { config += nprintf(` + authorization_key = "%{connection-authorization_key}"`, ctx) + } + if _, ok := ctx["zside-service_token"]; !ok { + if _, ok := ctx["connection-profile_uuid"]; ok { + config += nprintf(` profile_uuid = "%{connection-profile_uuid}"`, ctx) - } else { - config += nprintf(` + } else { + config += nprintf(` profile_uuid = data.equinix_ecx_l2_sellerprofile.pri.id`, ctx) + } } if _, ok := ctx["service_token"]; ok { config += nprintf(` service_token = "%{service_token}"`, ctx) - } + } + if _, ok := ctx["zside-service_token"]; ok { + config += nprintf(` + zside_service_token = "%{zside-service_token}"`, ctx) + } + if _, ok := ctx["zside-port_uuid"]; ok { + config += nprintf(` + zside_port_uuid = "%{zside-port_uuid}"`, ctx) + } if _, ok := ctx["connection-purchase_order_number"]; ok { config += nprintf(` purchase_order_number = "%{connection-purchase_order_number}"`, ctx) - } + } if _, ok := ctx["connection-seller_region"]; ok { config += nprintf(` seller_region = "%{connection-seller_region}"`, ctx) - } + } if _, ok := ctx["port-uuid"]; ok { config += nprintf(` port_uuid = "%{port-uuid}"`, ctx) - } else if _, ok := ctx["port-resourceName"]; ok { + } else if _, ok := ctx["port-resourceName"]; ok { config += nprintf(` port_uuid = data.equinix_ecx_port.%{port-resourceName}.id`, ctx) - } + } if _, ok := ctx["device-resourceName"]; ok { config += nprintf(` device_uuid = equinix_network_device.%{device-resourceName}.id`, ctx) - } + } if _, ok := ctx["connection-vlan_stag"]; ok { config += nprintf(` vlan_stag = %{connection-vlan_stag}`, ctx) - } + } if _, ok := ctx["connection-vlan_ctag"]; ok { config += nprintf(` vlan_ctag = %{connection-vlan_ctag}`, ctx) - } + } if _, ok := ctx["connection-named_tag"]; ok { config += nprintf(` named_tag = "%{connection-named_tag}"`, ctx) - } + } if _, ok := ctx["connection-device_interface_id"]; ok { config += nprintf(` device_interface_id = %{connection-device_interface_id}`, ctx) - } + } if _, ok := ctx["connection-secondary_name"]; ok { config += nprintf(` secondary_connection { name = "%{connection-secondary_name}"`, ctx) - if _, ok := ctx["connection-secondary_profile_name"]; ok { - config += nprintf(` + if _, ok := ctx["connection-secondary_profile_name"]; ok { + config += nprintf(` profile_uuid = data.equinix_ecx_l2_sellerprofile.sec.id`, ctx) - } - if _, ok := ctx["secondary-port_uuid"]; ok { - config += nprintf(` + } + if _, ok := ctx["secondary-port_uuid"]; ok { + config += nprintf(` port_uuid = "%{secondary-port_uuid}"`, ctx) - } else if _, ok := ctx["port-secondary_resourceName"]; ok { - config += nprintf(` + } else if _, ok := ctx["port-secondary_resourceName"]; ok { + config += nprintf(` port_uuid = data.equinix_ecx_port.%{port-secondary_resourceName}.id`, ctx) - } - if _, ok := ctx["device-secondary_name"]; ok { - config += nprintf(` + } + if _, ok := ctx["device-secondary_name"]; ok { + config += nprintf(` device_uuid = equinix_network_device.%{device-resourceName}.redundant_id`, ctx) - } - if _, ok := ctx["connection-secondary_vlan_stag"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_vlan_stag"]; ok { + config += nprintf(` vlan_stag = %{connection-secondary_vlan_stag}`, ctx) - } - if _, ok := ctx["connection-secondary_vlan_ctag"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_vlan_ctag"]; ok { + config += nprintf(` vlan_ctag = %{connection-secondary_vlan_ctag}`, ctx) - } - if _, ok := ctx["connection-secondary_device_interface_id"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_device_interface_id"]; ok { + config += nprintf(` device_interface_id = %{connection-secondary_device_interface_id}`, ctx) - } - if _, ok := ctx["connection-secondary_speed"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_speed"]; ok { + config += nprintf(` speed = %{connection-secondary_speed}`, ctx) - } - if _, ok := ctx["connection-secondary_speed_unit"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_speed_unit"]; ok { + config += nprintf(` speed_unit = "%{connection-secondary_speed_unit}"`, ctx) - } - if _, ok := ctx["connection-secondary_seller_metro_code"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_seller_metro_code"]; ok { + config += nprintf(` seller_metro_code = "%{connection-secondary_seller_metro_code}"`, ctx) - } - if _, ok := ctx["connection-secondary_seller_region"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_seller_region"]; ok { + config += nprintf(` seller_region = "%{connection-secondary_seller_region}"`, ctx) - } - if _, ok := ctx["connection-secondary_authorization_key"]; ok { - config += nprintf(` + } + if _, ok := ctx["connection-secondary_authorization_key"]; ok { + config += nprintf(` authorization_key = "%{connection-secondary_authorization_key}"`, ctx) - } - if _, ok := ctx["secondary-service_token"]; ok { - config += nprintf(` + } + if _, ok := ctx["secondary-service_token"]; ok { + config += nprintf(` service_token = "%{secondary-service_token}"`, ctx) - } - config += ` - }` } config += ` + }` + } + config += ` }` return config } diff --git a/equinix/resource_ecx_l2_connection_test.go b/equinix/resource_ecx_l2_connection_test.go index dfb767626..eef4764e9 100644 --- a/equinix/resource_ecx_l2_connection_test.go +++ b/equinix/resource_ecx_l2_connection_test.go @@ -79,6 +79,7 @@ func TestFabricL2Connection_updateResourceData(t *testing.T) { PortUUID: ecx.String(randString(36)), DeviceUUID: ecx.String(randString(36)), ServiceToken: ecx.String(randString(36)), + ZSideServiceToken: ecx.String(randString(36)), VlanSTag: ecx.Int(randInt(2000)), VlanCTag: ecx.Int(randInt(2000)), NamedTag: ecx.String(randString(100)), @@ -110,6 +111,7 @@ func TestFabricL2Connection_updateResourceData(t *testing.T) { assert.Equal(t, ecx.StringValue(input.DeviceUUID), d.Get(ecxL2ConnectionSchemaNames["DeviceUUID"]), "DeviceUUID matches") assert.Equal(t, ecx.IntValue(input.DeviceInterfaceID), d.Get(ecxL2ConnectionSchemaNames["DeviceInterfaceID"]), "DeviceInterfaceID matches") assert.Equal(t, ecx.StringValue(input.ServiceToken), d.Get(ecxL2ConnectionSchemaNames["ServiceToken"]), "ServiceToken matches") + assert.Equal(t, ecx.StringValue(input.ZSideServiceToken), d.Get(ecxL2ConnectionSchemaNames["ZSideServiceToken"]), "ZSideServiceToken matches") assert.Equal(t, ecx.IntValue(input.VlanSTag), d.Get(ecxL2ConnectionSchemaNames["VlanSTag"]), "VlanSTag matches") assert.Equal(t, ecx.IntValue(input.VlanCTag), d.Get(ecxL2ConnectionSchemaNames["VlanCTag"]), "VlanCTag matches") assert.Equal(t, ecx.StringValue(input.NamedTag), d.Get(ecxL2ConnectionSchemaNames["NamedTag"]), "NamedTag matches") From 736f9d254ef021ea3c845bd309c3cdab2a6b0d93 Mon Sep 17 00:00:00 2001 From: Oscar Cobles Date: Thu, 14 Jul 2022 09:14:03 -0500 Subject: [PATCH 3/6] update docs and examples --- docs/resources/equinix_ecx_l2_connection.md | 31 +++++++++-- docs/resources/equinix_metal_connection.md | 60 +++++++++++++++++++-- 2 files changed, 83 insertions(+), 8 deletions(-) diff --git a/docs/resources/equinix_ecx_l2_connection.md b/docs/resources/equinix_ecx_l2_connection.md index ecae3476c..9bcc60064 100644 --- a/docs/resources/equinix_ecx_l2_connection.md +++ b/docs/resources/equinix_ecx_l2_connection.md @@ -112,6 +112,25 @@ resource "equinix_ecx_l2_connection" "token-to-gcp" { } ``` +### Non-redundant Connection from own Equinix Port to an Equinix customer port using Z-Side Service token + +```hcl +data "equinix_ecx_port" "sv-qinq-pri" { + name = "CX-SV5-NL-Dot1q-BO-10G-PRI" +} + +resource "equinix_ecx_l2_connection" "port-to-token" { + name = "tf-port-token" + zside_service_token = "e9c22453-d3a7-4d5d-9112-d50173531392" + speed = 200 + speed_unit = "MB" + notifications = ["john@equinix.com", "marry@equinix.com"] + seller_metro_code = "FR" + port_uuid = data.equinix_ecx_port.sv-qinq-pri.id + vlan_stag = 1000 +} +``` + -> **NOTE:** See [Equinix Fabric connecting to the cloud](../guides/equinix_fabric_cloud_providers.md) guide for more details on how to connect to a CSP. @@ -134,10 +153,14 @@ the Network Edge virtual device from which the connection would originate. * `device_interface_id` - (Optional) Applicable with `device_uuid`, identifier of network interface on a given device, used for a connection. If not specified then first available interface will be selected. -* `service_token`- (Required when `port_uuid` or `device_uuid` are not set) - Unique Equinix Fabric -key given by a provider that grants you authorization to the Equinix Port or virtual device from -which the connection would originate. -More details in [A-Side Fabric Service Tokens](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/service%20tokens/Fabric-Service-Tokens.htm). +* `service_token`- (Required when `port_uuid` or `device_uuid` are not set) - A-side +service tokens authorize you to create a connection from a customer port, which created the token +for you, to a service profile or your own port. +More details in [A-Side Fabric Service Tokens](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/service%20tokens/Fabric-Service-Tokens.htm#:~:text=the%20service%20token.-,A%2DSide%20Service%20Tokens,-If%20you%20want). +* `zside_service_token`- (Required when `profile_uuid` or `zside_port_uuid` are not set) - Z-side +service tokens authorize you to create a connection from your port or virtual device to a customer +port which created the token for you. +More details in [Z-Side Fabric Service Tokens](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/service%20tokens/Fabric-Service-Tokens.htm#:~:text=requirements%20per%20provider.-,Z%2DSide%20Service%20Tokens,-If%20you%20want). -> **NOTE:** Service tokens can't be reused. To recreate a resource or to create a new one for another connection even from same interconnection asset, you will need to request another token diff --git a/docs/resources/equinix_metal_connection.md b/docs/resources/equinix_metal_connection.md index 949c335d2..cb8ab3036 100644 --- a/docs/resources/equinix_metal_connection.md +++ b/docs/resources/equinix_metal_connection.md @@ -10,16 +10,68 @@ Use this resource to request the creation an Interconnection asset to connect wi ## Example Usage +### Shared Connection with a_side token - Redundant Connection from Equinix Metal to a Cloud Service Provider + ```hcl -resource "equinix_metal_connection" "test" { - name = "My Interconnection" - project_id = equinix_metal_project.test.id +resource "equinix_metal_connection" "example" { + name = "tf-metal-to-azure" + project_id = local.project_id type = "shared" redundancy = "redundant" metro = "sv" - speed = "50Mbps" + speed = "1000Mbps" service_token_type = "a_side" } + +data "equinix_ecx_l2_sellerprofile" "example" { + name = "Azure ExpressRoute" + organization_global_name = "Microsoft" +} + +resource "equinix_ecx_l2_connection" "example" { + name = "tf-metal-to-azure" + profile_uuid = data.equinix_ecx_l2_sellerprofile.example.uuid + speed = azurerm_express_route_circuit.example.bandwidth_in_mbps + speed_unit = "MB" + notifications = ["example@equinix.com"] + service_token = equinix_metal_connection.example.service_tokens.0.id + seller_metro_code = "AM" + authorization_key = azurerm_express_route_circuit.example.service_key + named_tag = "PRIVATE" + secondary_connection { + name = "tf-metal-to-azure"-sec" + service_token = equinix_metal_connection.example.service_tokens.1.id + } +} +``` + +### Shared Connection with z_side token - Non-redundant Connection from your Equinix Fabric Port to Equinix Metal + +```hcl +resource "equinix_metal_connection" "example" { + name = "tf-port-to-metal" + project_id = local.project_id + type = "shared" + redundancy = "primary" + metro = "FR" + speed = "200Mbps" + service_token_type = "z_side" +} + +data "equinix_ecx_port" "example" { + name = "CX-FR5-NL-Dot1q-BO-1G-PRI" +} + +resource "equinix_ecx_l2_connection" "example" { + name = "tf-port-to-metal" + zside_service_token = equinix_metal_connection.example.service_tokens.0.id + speed = "200" + speed_unit = "MB" + notifications = ["example@equinix.com"] + seller_metro_code = "FR" + port_uuid = data.equinix_ecx_port.example.id + vlan_stag = 1020 +} ``` ## Argument Reference From dd21847a8f2f31ff3e289050e9232f2912c352c8 Mon Sep 17 00:00:00 2001 From: Oscar Cobles Date: Thu, 14 Jul 2022 09:33:22 -0500 Subject: [PATCH 4/6] update docs --- docs/resources/equinix_ecx_l2_connection.md | 16 ++++++++-------- docs/resources/equinix_metal_connection.md | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/resources/equinix_ecx_l2_connection.md b/docs/resources/equinix_ecx_l2_connection.md index 9bcc60064..8731e327e 100644 --- a/docs/resources/equinix_ecx_l2_connection.md +++ b/docs/resources/equinix_ecx_l2_connection.md @@ -9,7 +9,7 @@ layer 2 connections. ## Example Usage -### Non-redundant Connection from own Equinix Port +### Non-redundant Connection from own Equinix Fabric Port ```hcl data "equinix_ecx_l2_sellerprofile" "aws" { @@ -35,7 +35,7 @@ resource "equinix_ecx_l2_connection" "port-2-aws" { } ``` -### Redundant Connection from own Equinix Ports +### Redundant Connection from own Equinix Fabric Ports ```hcl data "equinix_ecx_l2_sellerprofile" "azure" { @@ -112,7 +112,7 @@ resource "equinix_ecx_l2_connection" "token-to-gcp" { } ``` -### Non-redundant Connection from own Equinix Port to an Equinix customer port using Z-Side Service token +### Non-redundant Connection from own Equinix Fabric Port to an Equinix customer port using Z-Side Service token ```hcl data "equinix_ecx_port" "sv-qinq-pri" { @@ -147,7 +147,7 @@ hyphens and underscores notifications. * `purchase_order_number` - (Optional) Connection's purchase order number to reflect on the invoice * `port_uuid` - (Required when `device_uuid` or `service_token` are not set) Unique identifier of -the Equinix port from which the connection would originate. +the Equinix Fabric Port from which the connection would originate. * `device_uuid` - (Required when `port_uuid` or `service_token` are not set) Unique identifier of the Network Edge virtual device from which the connection would originate. * `device_interface_id` - (Optional) Applicable with `device_uuid`, identifier of network interface @@ -159,7 +159,7 @@ for you, to a service profile or your own port. More details in [A-Side Fabric Service Tokens](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/service%20tokens/Fabric-Service-Tokens.htm#:~:text=the%20service%20token.-,A%2DSide%20Service%20Tokens,-If%20you%20want). * `zside_service_token`- (Required when `profile_uuid` or `zside_port_uuid` are not set) - Z-side service tokens authorize you to create a connection from your port or virtual device to a customer -port which created the token for you. +port which created the token for you. `zside_service_token` cannot be used with `secondary_connection`. More details in [Z-Side Fabric Service Tokens](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/service%20tokens/Fabric-Service-Tokens.htm#:~:text=requirements%20per%20provider.-,Z%2DSide%20Service%20Tokens,-If%20you%20want). -> **NOTE:** Service tokens can't be reused. To recreate a resource or to create a new one for @@ -210,7 +210,7 @@ connectivity. See [Secondary Connection](#secondary-connection) below for more d -> **NOTE:** Some service provider do not directly support redundant connections in their service profiles. However, some of them offer active/active (BGP multipath) or active/passive (failover) -configurations in their platforms and you can still achieve that highly resilient network +configurations in their platforms and you still achieve that highly resilient network connections by creating an `equinix_ecx_l2_connection` resource for each connection instead of defining a `secondary_connection` block. @@ -221,7 +221,7 @@ The `secondary_connection` block supports the following arguments: specified primary `speed` will be used. * `speed_unit` - (Optional) Unit of the speed/bandwidth to be allocated to the secondary connection. If not specified primary `speed_unit` will be used. -* `port_uuid` - (Optional) Applicable with primary `port_uuid`. Identifier of the Equinix port from +* `port_uuid` - (Optional) Applicable with primary `port_uuid`. Identifier of the Equinix Fabric Port from which the secondary connection would originate. If not specified primary `port_uuid` will be used. * `device_uuid` - (Optional) Applicable with primary `device_uuid`. Identifier of the Network Edge virtual device from which the secondary connection would originate. If not specified primary @@ -229,7 +229,7 @@ virtual device from which the secondary connection would originate. If not speci * `device_interface_id` - (Optional) Applicable with `device_uuid`, identifier of network interface on a given device. If not specified then first available interface will be selected. * `service_token`- (Optional) Required with primary `service_token`. Unique Equinix Fabric key -given by a provider that grants you authorization to enable connectivity from an Equinix Port or +given by a provider that grants you authorization to enable connectivity from an Equinix Fabric Port or virtual device. Each connection (primary and secondary) requires a separate token. More details in [Fabric Service Tokens](https://docs.equinix.com/en-us/Content/Interconnection/Fabric/service%20tokens/Fabric-Service-Tokens.htm). * `vlan_stag` - (Required when `port_uuid` is set) S-Tag/Outer-Tag of the secondary connection, a diff --git a/docs/resources/equinix_metal_connection.md b/docs/resources/equinix_metal_connection.md index cb8ab3036..60a7b9559 100644 --- a/docs/resources/equinix_metal_connection.md +++ b/docs/resources/equinix_metal_connection.md @@ -45,7 +45,7 @@ resource "equinix_ecx_l2_connection" "example" { } ``` -### Shared Connection with z_side token - Non-redundant Connection from your Equinix Fabric Port to Equinix Metal +### Shared Connection with z_side token - Non-redundant Connection from your own Equinix Fabric Port to Equinix Metal ```hcl resource "equinix_metal_connection" "example" { From 743a22b5670d7b22b86089aa42c0903c77484d66 Mon Sep 17 00:00:00 2001 From: Oscar Cobles Date: Fri, 15 Jul 2022 07:15:19 -0500 Subject: [PATCH 5/6] added attribute vendor_token to equinix_ecx_l2_connection and match API behavoir --- docs/resources/equinix_ecx_l2_connection.md | 12 ++++- equinix/resource_ecx_l2_connection.go | 44 +++++++++++++++---- .../resource_ecx_l2_connection_acc_test.go | 18 ++++---- equinix/resource_ecx_l2_connection_test.go | 23 +++++++--- go.mod | 2 +- go.sum | 2 + 6 files changed, 76 insertions(+), 25 deletions(-) diff --git a/docs/resources/equinix_ecx_l2_connection.md b/docs/resources/equinix_ecx_l2_connection.md index 8731e327e..09a2af98d 100644 --- a/docs/resources/equinix_ecx_l2_connection.md +++ b/docs/resources/equinix_ecx_l2_connection.md @@ -261,12 +261,15 @@ assigned by the Fabric. * `zside_vlan_stag` - When not provided as an argument, it is S-Tag/Outer-Tag of the connection on the Z side, assigned by the Fabric. * `actions` - One or more pending actions to complete connection provisioning. +* `vendor_token` - The Equinix Fabric Token the connection was created with. Applicable if the +connection was created with a `service_token` (a-side) or `zside_service_token` (z-side). * `secondary_connection`: * `zside_port_uuid` * `zside_vlan_stag` * `zside_vlan_ctag` * `redundancy_type` * `redundancy_group` + * `vendor_token` ## Update operation behavior @@ -289,6 +292,9 @@ options: ## Import +-> **NOTE:** Connections created with a Service Token (both a-side/z-side), will populate the token +into `vendor_token` but `service_token` and `zside_service_token` will remain empty. + Equinix L2 connections can be imported using an existing `id`: ```sh @@ -296,8 +302,10 @@ existing_connection_id='example-uuid-1' terraform import equinix_ecx_l2_connection.example ${existing_connection_id} ``` -**Please Note** that to import a redundant connection you must concatenate `id` of both connections -(primary and secondary) into a single string separated by `:`, e.g., +-> **NOTE:** To import a redundant connection you must concatenate `id` of both connections +(primary and secondary) into a single string separated by `:`. + +To import a redundant Equinix L2 connection: ```sh existing_primary_connection_id='example-uuid-1' diff --git a/equinix/resource_ecx_l2_connection.go b/equinix/resource_ecx_l2_connection.go index bbd589656..23dba1dae 100644 --- a/equinix/resource_ecx_l2_connection.go +++ b/equinix/resource_ecx_l2_connection.go @@ -45,6 +45,7 @@ var ecxL2ConnectionSchemaNames = map[string]string{ "SecondaryConnection": "secondary_connection", "Actions": "actions", "ServiceToken": "service_token", + "VendorToken": "vendor_token", } var ecxL2ConnectionDescriptions = map[string]string{ @@ -77,6 +78,7 @@ var ecxL2ConnectionDescriptions = map[string]string{ "SecondaryConnection": "Definition of secondary connection for redundant, HA connectivity", "Actions": "One or more pending actions to complete connection provisioning", "ServiceToken": "Unique Equinix Fabric key given by a provider that grants you authorization to enable connectivity from a shared multi-tenant port (a-side)", + "VendorToken": "The Equinix Fabric Token the connection was created with. Applicable if the connection was created with a ServiceToken (a-side) or ZSideServiceToken (z-side)", } var ecxL2ConnectionAdditionalInfoSchemaNames = map[string]string{ @@ -385,6 +387,11 @@ func createECXL2ConnectionResourceSchema() map[string]*schema.Schema { }, Description: ecxL2ConnectionDescriptions["ZSideServiceToken"], }, + ecxL2ConnectionSchemaNames["VendorToken"]: { + Type: schema.TypeString, + Computed: true, + Description: ecxL2ConnectionDescriptions["VendorToken"], + }, } } @@ -612,6 +619,11 @@ func createECXL2ConnectionSecondaryResourceSchema() map[string]*schema.Schema { }, Description: ecxL2ConnectionDescriptions["ServiceToken"], }, + ecxL2ConnectionSchemaNames["VendorToken"]: { + Type: schema.TypeString, + Computed: true, + Description: ecxL2ConnectionDescriptions["VendorToken"], + }, } } @@ -930,11 +942,22 @@ func updateECXL2ConnectionResource(primary *ecx.L2Connection, secondary *ecx.L2C if err := d.Set(ecxL2ConnectionSchemaNames["RedundancyGroup"], primary.RedundancyGroup); err != nil { return fmt.Errorf("error reading RedundancyGroup: %s", err) } - if err := d.Set(ecxL2ConnectionSchemaNames["ServiceToken"], primary.ServiceToken); err != nil { - return fmt.Errorf("error reading ServiceToken: %s", err) + if err := d.Set(ecxL2ConnectionSchemaNames["VendorToken"], primary.VendorToken); err != nil { + return fmt.Errorf("error reading VendorToken: %s", err) + } + if v, ok := d.GetOk(ecxL2ConnectionSchemaNames["ServiceToken"]); ok { + if ecx.StringValue(primary.VendorToken) != v.(string){ + if err := d.Set(ecxL2ConnectionSchemaNames["ServiceToken"], primary.VendorToken); err != nil { + return fmt.Errorf("error reading ServiceToken: %s", err) + } + } } - if err := d.Set(ecxL2ConnectionSchemaNames["ZSideServiceToken"], primary.ZSideServiceToken); err != nil { - return fmt.Errorf("error reading ZSideServiceToken: %s", err) + if v, ok := d.GetOk(ecxL2ConnectionSchemaNames["ZSideServiceToken"]); ok { + if ecx.StringValue(primary.VendorToken) != v.(string){ + if err := d.Set(ecxL2ConnectionSchemaNames["ZSideServiceToken"], primary.VendorToken); err != nil { + return fmt.Errorf("error reading ZSideServiceToken: %s", err) + } + } } if err := d.Set(ecxL2ConnectionSchemaNames["Actions"], flattenECXL2ConnectionActions(primary.Actions)); err != nil { return fmt.Errorf("error reading Actions: %s", err) @@ -963,9 +986,6 @@ func flattenECXL2ConnectionSecondary(previous, conn *ecx.L2Connection) interface transformed[ecxL2ConnectionSchemaNames["PortUUID"]] = conn.PortUUID transformed[ecxL2ConnectionSchemaNames["DeviceUUID"]] = conn.DeviceUUID transformed[ecxL2ConnectionSchemaNames["DeviceInterfaceID"]] = conn.DeviceInterfaceID - if previous != nil { - transformed[ecxL2ConnectionSchemaNames["DeviceInterfaceID"]] = previous.DeviceInterfaceID - } transformed[ecxL2ConnectionSchemaNames["VlanSTag"]] = conn.VlanSTag transformed[ecxL2ConnectionSchemaNames["VlanCTag"]] = conn.VlanCTag transformed[ecxL2ConnectionSchemaNames["ZSidePortUUID"]] = conn.ZSidePortUUID @@ -977,7 +997,15 @@ func flattenECXL2ConnectionSecondary(previous, conn *ecx.L2Connection) interface transformed[ecxL2ConnectionSchemaNames["RedundancyType"]] = conn.RedundancyType transformed[ecxL2ConnectionSchemaNames["RedundancyGroup"]] = conn.RedundancyGroup transformed[ecxL2ConnectionSchemaNames["Actions"]] = flattenECXL2ConnectionActions(conn.Actions) - transformed[ecxL2ConnectionSchemaNames["ServiceToken"]] = conn.ServiceToken + transformed[ecxL2ConnectionSchemaNames["VendorToken"]] = conn.VendorToken + if previous != nil { + transformed[ecxL2ConnectionSchemaNames["DeviceInterfaceID"]] = previous.DeviceInterfaceID + transformed[ecxL2ConnectionSchemaNames["ServiceToken"]] = previous.ServiceToken + prevSToken := ecx.StringValue(previous.ServiceToken) + if prevSToken != "" && ecx.StringValue(conn.VendorToken) != prevSToken { + transformed[ecxL2ConnectionSchemaNames["ServiceToken"]] = conn.VendorToken + } + } return []interface{}{transformed} } diff --git a/equinix/resource_ecx_l2_connection_acc_test.go b/equinix/resource_ecx_l2_connection_acc_test.go index 6889c6a1d..acbfe8ee5 100644 --- a/equinix/resource_ecx_l2_connection_acc_test.go +++ b/equinix/resource_ecx_l2_connection_acc_test.go @@ -341,12 +341,12 @@ func TestAccFabricL2Connection_ServiceToken_HA_SP(t *testing.T) { if uuid == priConnID { connection.UUID = &priConnID connection.Name = &priConnName - connection.ServiceToken = &priServiceToken + connection.VendorToken = &priServiceToken connection.PortUUID = &priPortUUID } else { connection.UUID = &secConnID connection.Name = &secConnName - connection.ServiceToken = &secServiceToken + connection.VendorToken = &secServiceToken connection.PortUUID = &secPortUUID } return &connection, nil @@ -387,10 +387,12 @@ func TestAccFabricL2Connection_ServiceToken_HA_SP(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "status", ecx.ConnectionStatusProvisioned), resource.TestCheckResourceAttrSet(resourceName, "service_token"), + resource.TestCheckResourceAttrPair(resourceName, "vendor_token", resourceName, "service_token"), resource.TestCheckResourceAttrSet(resourceName, "port_uuid"), resource.TestCheckResourceAttr(resourceName, "secondary_connection.0.status", ecx.ConnectionStatusProvisioned), resource.TestCheckResourceAttrSet(resourceName, "secondary_connection.0.port_uuid"), - resource.TestCheckResourceAttrSet(resourceName, "secondary_connection.0.service_token"), + resource.TestCheckResourceAttrSet(resourceName, "secondary_connection.0.vendor_token"), + resource.TestCheckResourceAttrPair(resourceName, "secondary_connection.0.vendor_token", resourceName, "secondary_connection.0.service_token"), ), }, { @@ -411,6 +413,7 @@ func TestAccFabricL2Connection_ServiceToken_HA_SP(t *testing.T) { }, ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"service_token", "secondary_connection.0.service_token"}, }, }, }) @@ -470,17 +473,14 @@ func TestAccFabricL2Connection_ZSideServiceToken_Single(t *testing.T) { Speed: &speed, SpeedUnit: &speedUnit, Notifications: notifications, - ProfileUUID: &sellerProfileUUID, Status: &status, - AuthorizationKey: &authKey, SellerMetroCode: &sellerMetro, RedundancyGroup: &redundancyGroupUUID, RedundancyType: &redundancyType, UUID: &priConnID, Name: &priConnName, - ZSideServiceToken: &priZSideServiceToken, PortUUID: &priPortUUID, - ZSidePortUUID: &priZSidePortUUID, + VendorToken: &priZSideServiceToken, } return &connection, nil }, @@ -520,6 +520,7 @@ func TestAccFabricL2Connection_ZSideServiceToken_Single(t *testing.T) { Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "status", ecx.ConnectionStatusProvisioned), resource.TestCheckResourceAttrSet(resourceName, "zside_service_token"), + resource.TestCheckResourceAttrPair(resourceName, "vendor_token", resourceName, "zside_service_token"), resource.TestCheckResourceAttrSet(resourceName, "port_uuid"), ), }, @@ -527,6 +528,7 @@ func TestAccFabricL2Connection_ZSideServiceToken_Single(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{"zside_service_token"}, }, }, }) @@ -836,7 +838,7 @@ resource "equinix_ecx_l2_connection" "%{connection-resourceName}" { } if _, ok := ctx["secondary-service_token"]; ok { config += nprintf(` - service_token = "%{secondary-service_token}"`, ctx) + service_token = "%{secondary-service_token}"`, ctx) } config += ` }` diff --git a/equinix/resource_ecx_l2_connection_test.go b/equinix/resource_ecx_l2_connection_test.go index eef4764e9..219ee7db7 100644 --- a/equinix/resource_ecx_l2_connection_test.go +++ b/equinix/resource_ecx_l2_connection_test.go @@ -29,6 +29,7 @@ func TestFabricL2Connection_createFromResourceData(t *testing.T) { ecxL2ConnectionSchemaNames["SellerMetroCode"]: "SV", ecxL2ConnectionSchemaNames["AuthorizationKey"]: "123456789012", ecxL2ConnectionSchemaNames["ServiceToken"]: "1c356a7b-d632-18a5-c357-a33146cab65d", + ecxL2ConnectionSchemaNames["ZSideServiceToken"]: "febc9d80-11e0-4dc8-8eb8-c41b6b378df2", } d := schema.TestResourceDataRaw(t, createECXL2ConnectionResourceSchema(), rawData) d.Set(ecxL2ConnectionSchemaNames["Notifications"], []string{"test@test.com"}) @@ -52,6 +53,7 @@ func TestFabricL2Connection_createFromResourceData(t *testing.T) { SellerMetroCode: ecx.String(rawData[ecxL2ConnectionSchemaNames["SellerMetroCode"]].(string)), AuthorizationKey: ecx.String(rawData[ecxL2ConnectionSchemaNames["AuthorizationKey"]].(string)), ServiceToken: ecx.String(rawData[ecxL2ConnectionSchemaNames["ServiceToken"]].(string)), + ZSideServiceToken: ecx.String(rawData[ecxL2ConnectionSchemaNames["ZSideServiceToken"]].(string)), } // when @@ -78,8 +80,7 @@ func TestFabricL2Connection_updateResourceData(t *testing.T) { PurchaseOrderNumber: ecx.String(randString(10)), PortUUID: ecx.String(randString(36)), DeviceUUID: ecx.String(randString(36)), - ServiceToken: ecx.String(randString(36)), - ZSideServiceToken: ecx.String(randString(36)), + VendorToken: ecx.String(randString(36)), VlanSTag: ecx.Int(randInt(2000)), VlanCTag: ecx.Int(randInt(2000)), NamedTag: ecx.String(randString(100)), @@ -93,6 +94,11 @@ func TestFabricL2Connection_updateResourceData(t *testing.T) { RedundancyGroup: ecx.String(randString(36)), RedundancyType: ecx.String(randString(10)), } + prevServiceToken := ecx.String(randString(20)) + d.Set(ecxL2ConnectionSchemaNames["ServiceToken"], prevServiceToken) + prevZsideServiceToken := ecx.String(randString(20)) + d.Set(ecxL2ConnectionSchemaNames["ZSideServiceToken"], prevZsideServiceToken) + // when err := updateECXL2ConnectionResource(input, nil, d) @@ -110,8 +116,11 @@ func TestFabricL2Connection_updateResourceData(t *testing.T) { assert.Equal(t, ecx.StringValue(input.PortUUID), d.Get(ecxL2ConnectionSchemaNames["PortUUID"]), "PortUUID matches") assert.Equal(t, ecx.StringValue(input.DeviceUUID), d.Get(ecxL2ConnectionSchemaNames["DeviceUUID"]), "DeviceUUID matches") assert.Equal(t, ecx.IntValue(input.DeviceInterfaceID), d.Get(ecxL2ConnectionSchemaNames["DeviceInterfaceID"]), "DeviceInterfaceID matches") - assert.Equal(t, ecx.StringValue(input.ServiceToken), d.Get(ecxL2ConnectionSchemaNames["ServiceToken"]), "ServiceToken matches") - assert.Equal(t, ecx.StringValue(input.ZSideServiceToken), d.Get(ecxL2ConnectionSchemaNames["ZSideServiceToken"]), "ZSideServiceToken matches") + assert.Equal(t, ecx.StringValue(input.VendorToken), d.Get(ecxL2ConnectionSchemaNames["VendorToken"]), "VendorToken matches") + assert.Equal(t, ecx.StringValue(input.VendorToken), d.Get(ecxL2ConnectionSchemaNames["ServiceToken"]), "ServiceToken and VendorToken match") + assert.NotEqual(t, ecx.StringValue(prevServiceToken), d.Get(ecxL2ConnectionSchemaNames["ServiceToken"]), "ServiceToken updated") + assert.Equal(t, ecx.StringValue(input.VendorToken), d.Get(ecxL2ConnectionSchemaNames["ZSideServiceToken"]), "ZSideServiceToken and VendorToken match") + assert.NotEqual(t, ecx.StringValue(prevZsideServiceToken), d.Get(ecxL2ConnectionSchemaNames["ZSideServiceToken"]), "ZSideServiceToken updated") assert.Equal(t, ecx.IntValue(input.VlanSTag), d.Get(ecxL2ConnectionSchemaNames["VlanSTag"]), "VlanSTag matches") assert.Equal(t, ecx.IntValue(input.VlanCTag), d.Get(ecxL2ConnectionSchemaNames["VlanCTag"]), "VlanCTag matches") assert.Equal(t, ecx.StringValue(input.NamedTag), d.Get(ecxL2ConnectionSchemaNames["NamedTag"]), "NamedTag matches") @@ -148,10 +157,11 @@ func TestFabricL2Connection_flattenSecondary(t *testing.T) { AuthorizationKey: ecx.String(randString(10)), RedundancyGroup: ecx.String(randString(10)), RedundancyType: ecx.String(randString(10)), - ServiceToken: ecx.String(randString(36)), + VendorToken: ecx.String(randString(36)), } previousInput := &ecx.L2Connection{ DeviceInterfaceID: ecx.Int(randInt(10)), + ServiceToken: ecx.String(randString(36)), } expected := []interface{}{ map[string]interface{}{ @@ -176,7 +186,8 @@ func TestFabricL2Connection_flattenSecondary(t *testing.T) { ecxL2ConnectionSchemaNames["RedundancyGroup"]: input.RedundancyGroup, ecxL2ConnectionSchemaNames["RedundancyType"]: input.RedundancyType, ecxL2ConnectionSchemaNames["Actions"]: []interface{}{}, - ecxL2ConnectionSchemaNames["ServiceToken"]: input.ServiceToken, + ecxL2ConnectionSchemaNames["ServiceToken"]: input.VendorToken, + ecxL2ConnectionSchemaNames["VendorToken"]: input.VendorToken, }, } diff --git a/go.mod b/go.mod index 10eb8826e..df4f78422 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/equinix/terraform-provider-equinix go 1.17 require ( - github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095 + github.com/equinix/ecx-go/v2 v2.2.1-0.20220715091446-0d7d6eee8bc5 github.com/equinix/ne-go v1.6.0 github.com/equinix/oauth2-go v1.0.0 github.com/equinix/rest-go v1.3.0 diff --git a/go.sum b/go.sum index f25db37d8..6517a5730 100644 --- a/go.sum +++ b/go.sum @@ -99,6 +99,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095 h1:Hzncnz4Ni3ZF3doZR2bgVgq5QyB3AEmA9scykqPiBlk= github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= +github.com/equinix/ecx-go/v2 v2.2.1-0.20220715091446-0d7d6eee8bc5 h1:/uHyhExXyBLom3GkTcNa+1gDPVEy9dvTgKwWG3aH96w= +github.com/equinix/ecx-go/v2 v2.2.1-0.20220715091446-0d7d6eee8bc5/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= github.com/equinix/ne-go v1.6.0 h1:jp95igkZoMi161wycIIzvQiW2Vyh2Uy5GnOICZ7CjSQ= github.com/equinix/ne-go v1.6.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI= github.com/equinix/oauth2-go v1.0.0 h1:fHtAPGq82PdgtK5vEThs8Vwz6f7D/8SX4tE3NJu+KcU= From bb71256af33bffe3a16d9631ee7d18b13039d13c Mon Sep 17 00:00:00 2001 From: Oscar Cobles Date: Fri, 15 Jul 2022 10:08:16 -0500 Subject: [PATCH 6/6] udpate ecx-go to v2.3.0 --- go.mod | 2 +- go.sum | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index df4f78422..d6d43a2e4 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/equinix/terraform-provider-equinix go 1.17 require ( - github.com/equinix/ecx-go/v2 v2.2.1-0.20220715091446-0d7d6eee8bc5 + github.com/equinix/ecx-go/v2 v2.3.0 github.com/equinix/ne-go v1.6.0 github.com/equinix/oauth2-go v1.0.0 github.com/equinix/rest-go v1.3.0 diff --git a/go.sum b/go.sum index 6517a5730..0a66e993a 100644 --- a/go.sum +++ b/go.sum @@ -97,10 +97,8 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095 h1:Hzncnz4Ni3ZF3doZR2bgVgq5QyB3AEmA9scykqPiBlk= -github.com/equinix/ecx-go/v2 v2.2.1-0.20220713144045-34e67110c095/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= -github.com/equinix/ecx-go/v2 v2.2.1-0.20220715091446-0d7d6eee8bc5 h1:/uHyhExXyBLom3GkTcNa+1gDPVEy9dvTgKwWG3aH96w= -github.com/equinix/ecx-go/v2 v2.2.1-0.20220715091446-0d7d6eee8bc5/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= +github.com/equinix/ecx-go/v2 v2.3.0 h1:SOABrI2TP073Mx3gVoWa4qGlot1Z2hECAOY8W4nYDPU= +github.com/equinix/ecx-go/v2 v2.3.0/go.mod h1:FvCdZ3jXU8Z4CPKig2DT+4J2HdwgRK17pIcznM7RXyk= github.com/equinix/ne-go v1.6.0 h1:jp95igkZoMi161wycIIzvQiW2Vyh2Uy5GnOICZ7CjSQ= github.com/equinix/ne-go v1.6.0/go.mod h1:eHkkxM4nbTB7DZ9X9zGnwfYnxIJWIsU3aHA+FAoZ1EI= github.com/equinix/oauth2-go v1.0.0 h1:fHtAPGq82PdgtK5vEThs8Vwz6f7D/8SX4tE3NJu+KcU=