diff --git a/docs/data-sources/equinix_fabric_connection.md b/docs/data-sources/equinix_fabric_connection.md
index e15f9f809..628a31cbb 100644
--- a/docs/data-sources/equinix_fabric_connection.md
+++ b/docs/data-sources/equinix_fabric_connection.md
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "equinix_fabric_connection Data Source - terraform-provider-equinix"
-subcategory: "Fabric"
+subcategory: ""
description: |-
Fabric V4 API compatible data resource that allow user to fetch connection for a given UUID
---
@@ -17,7 +17,6 @@ Fabric V4 API compatible data resource that allow user to fetch connection for a
### Optional
-- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project))
- `uuid` (String) Equinix-assigned connection identifier
### Read-Only
@@ -36,23 +35,12 @@ Fabric V4 API compatible data resource that allow user to fetch connection for a
- `notifications` (List of Object) Preferences for notifications on connection configuration or status changes (see [below for nested schema](#nestedatt--notifications))
- `operation` (Set of Object) Connection specific operational data (see [below for nested schema](#nestedatt--operation))
- `order` (Set of Object) Order related to this connection information (see [below for nested schema](#nestedatt--order))
+- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project))
- `redundancy` (Set of Object) Redundancy Information (see [below for nested schema](#nestedatt--redundancy))
- `state` (String) Connection overall state
- `type` (String) Defines the connection type like VG_VC, EVPL_VC, EPL_VC, EC_VC, GW_VC, ACCESS_EPL_VC
- `z_side` (Set of Object) Destination or Provider side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedatt--z_side))
-
-### Nested Schema for `project`
-
-Optional:
-
-- `project_id` (String) Project Id
-
-Read-Only:
-
-- `href` (String) Unique Resource URL
-
-
### Nested Schema for `a_side`
@@ -342,6 +330,15 @@ Read-Only:
- `purchase_order_number` (String)
+
+### Nested Schema for `project`
+
+Read-Only:
+
+- `href` (String) Unique Resource URL
+- `project_id` (String) Project Id
+
+
### Nested Schema for `redundancy`
@@ -542,5 +539,3 @@ Read-Only:
- `href` (String)
- `type` (String)
- `uuid` (String)
-
-
diff --git a/docs/data-sources/equinix_fabric_port.md b/docs/data-sources/equinix_fabric_port.md
index d61dcfd67..39e1ad8ee 100644
--- a/docs/data-sources/equinix_fabric_port.md
+++ b/docs/data-sources/equinix_fabric_port.md
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "equinix_fabric_port Data Source - terraform-provider-equinix"
-subcategory: "Fabric"
+subcategory: ""
description: |-
Fabric V4 API compatible data resource that allow user to fetch port by uuid
---
@@ -141,5 +141,3 @@ Read-Only:
- `enabled` (Boolean)
- `group` (Number)
- `priority` (String)
-
-
diff --git a/docs/data-sources/equinix_fabric_ports.md b/docs/data-sources/equinix_fabric_ports.md
index 67842293b..ddfb4525a 100644
--- a/docs/data-sources/equinix_fabric_ports.md
+++ b/docs/data-sources/equinix_fabric_ports.md
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "equinix_fabric_ports Data Source - terraform-provider-equinix"
-subcategory: "Fabric"
+subcategory: ""
description: |-
Fabric V4 API compatible data resource that allow user to fetch port by name
---
@@ -157,5 +157,3 @@ Read-Only:
- `enabled` (Boolean)
- `group` (Number)
- `priority` (String)
-
-
diff --git a/docs/data-sources/equinix_fabric_service_profile.md b/docs/data-sources/equinix_fabric_service_profile.md
index d3e46c044..4bb6cf11b 100644
--- a/docs/data-sources/equinix_fabric_service_profile.md
+++ b/docs/data-sources/equinix_fabric_service_profile.md
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "equinix_fabric_service_profile Data Source - terraform-provider-equinix"
-subcategory: "Fabric"
+subcategory: ""
description: |-
Fabric V4 API compatible data resource that allow user to fetch Service Profile by UUID filter criteria
---
@@ -220,5 +220,3 @@ Read-Only:
- `href` (String)
- `project_id` (String)
-
-
diff --git a/docs/data-sources/equinix_fabric_service_profiles.md b/docs/data-sources/equinix_fabric_service_profiles.md
index c5870b631..8e34b9ff2 100644
--- a/docs/data-sources/equinix_fabric_service_profiles.md
+++ b/docs/data-sources/equinix_fabric_service_profiles.md
@@ -1,7 +1,7 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "equinix_fabric_service_profiles Data Source - terraform-provider-equinix"
-subcategory: "Fabric"
+subcategory: ""
description: |-
Fabric V4 API compatible data resource that allow user to fetch Service Profile by name filter criteria
---
@@ -245,5 +245,3 @@ Read-Only:
- `href` (String)
- `project_id` (String)
-
-
diff --git a/docs/resources/equinix_fabric_connection.md b/docs/resources/equinix_fabric_connection.md
index d6272ba0e..1857cb5bc 100644
--- a/docs/resources/equinix_fabric_connection.md
+++ b/docs/resources/equinix_fabric_connection.md
@@ -26,22 +26,21 @@ Fabric V4 API compatible resource allows creation and management of Equinix Fabr
### Optional
-- `account` (Block Set) Customer account information that is associated with this connection (see [below for nested schema](#nestedblock--account))
- `additional_info` (Block List) Connection additional information (see [below for nested schema](#nestedblock--additional_info))
-- `description` (String) Customer-provided connection description
- `order` (Block Set) Order related to this connection information (see [below for nested schema](#nestedblock--order))
-- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project))
- `redundancy` (Block Set) Redundancy Information (see [below for nested schema](#nestedblock--redundancy))
- `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
### Read-Only
+- `account` (Set of Object) Customer account information that is associated with this connection (see [below for nested schema](#nestedatt--account))
- `change_log` (Set of Object) Captures connection lifecycle change information (see [below for nested schema](#nestedatt--change_log))
- `direction` (String) Connection directionality from the requester point of view
- `href` (String) Connection URI information
- `id` (String) The ID of this resource.
- `is_remote` (Boolean) Connection property derived from access point locations
- `operation` (Set of Object) Connection type-specific operational data (see [below for nested schema](#nestedatt--operation))
+- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project))
- `state` (String) Connection overall state
@@ -58,7 +57,6 @@ Optional:
Optional:
-- `account` (Block Set) Account (see [below for nested schema](#nestedblock--a_side--access_point--account))
- `authentication_key` (String) Authentication key for provider based connections
- `gateway` (Block Set) Gateway access point information (see [below for nested schema](#nestedblock--a_side--access_point--gateway))
- `interface` (Block Set) Virtual device interface (see [below for nested schema](#nestedblock--a_side--access_point--interface))
@@ -73,43 +71,30 @@ Optional:
- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW
- `virtual_device` (Block Set) Virtual device (see [below for nested schema](#nestedblock--a_side--access_point--virtual_device))
-
-### Nested Schema for `a_side.access_point.account`
-
-Optional:
-
-- `account_name` (String) Account Name
-- `account_number` (Number) Account Number
-- `global_cust_id` (String) Global Customer organization identifier
-- `global_org_id` (String) Global organization identifier
-- `global_organization_name` (String) Global organization name
-- `org_id` (Number) Customer organization identifier
-- `organization_name` (String) Customer organization name
+Read-Only:
+- `account` (Set of Object) Account (see [below for nested schema](#nestedatt--a_side--access_point--account))
### Nested Schema for `a_side.access_point.gateway`
Optional:
-- `project` (Block Set) Project this gateway created in (see [below for nested schema](#nestedblock--a_side--access_point--gateway--project))
+- `href` (String) Unique Resource Identifier
- `uuid` (String) Equinix-assigned virtual gateway identifier
Read-Only:
-- `href` (String) Unique Resource Identifier
+- `project` (Set of Object) Project in which this gateway is created (see [below for nested schema](#nestedatt--a_side--access_point--gateway--project))
- `state` (String) Virtual Gateway state
-
+
### Nested Schema for `a_side.access_point.gateway.project`
-Optional:
-
-- `project_id` (String) Project Id
-
Read-Only:
-- `href` (String) Unique Resource URL
+- `href` (String)
+- `project_id` (String)
@@ -153,37 +138,37 @@ Optional:
Optional:
-- `name` (String) Port name
-- `redundancy` (Block Set) Redundancy Information (see [below for nested schema](#nestedblock--a_side--access_point--port--redundancy))
- `uuid` (String) Equinix-assigned Port identifier
Read-Only:
- `href` (String) Unique Resource Identifier
+- `name` (String) Port name
+- `redundancy` (Set of Object) Redundancy Information (see [below for nested schema](#nestedatt--a_side--access_point--port--redundancy))
-
+
### Nested Schema for `a_side.access_point.port.redundancy`
-Optional:
+Read-Only:
-- `priority` (String) Priority type- PRIMARY, SECONDARY
+- `priority` (String)
### Nested Schema for `a_side.access_point.profile`
-Optional:
+Required:
-- `description` (String) User-provided service description
-- `name` (String) Customer-assigned service profile name
- `type` (String) Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE
- `uuid` (String) Equinix assigned service profile identifier
Read-Only:
- `access_point_type_configs` (List of Object) Access point config information (see [below for nested schema](#nestedatt--a_side--access_point--profile--access_point_type_configs))
+- `description` (String) User-provided service description
- `href` (String) Service Profile URI response attribute
+- `name` (String) Customer-assigned service profile name
### Nested Schema for `a_side.access_point.profile.access_point_type_configs`
@@ -218,6 +203,20 @@ Read-Only:
- `href` (String) Unique Resource Identifier
+
+### Nested Schema for `a_side.access_point.account`
+
+Read-Only:
+
+- `account_name` (String)
+- `account_number` (Number)
+- `global_cust_id` (String)
+- `global_org_id` (String)
+- `global_organization_name` (String)
+- `org_id` (Number)
+- `organization_name` (String)
+
+
### Nested Schema for `a_side.additional_info`
@@ -270,7 +269,6 @@ Optional:
Optional:
-- `account` (Block Set) Account (see [below for nested schema](#nestedblock--z_side--access_point--account))
- `authentication_key` (String) Authentication key for provider based connections
- `gateway` (Block Set) Gateway access point information (see [below for nested schema](#nestedblock--z_side--access_point--gateway))
- `interface` (Block Set) Virtual device interface (see [below for nested schema](#nestedblock--z_side--access_point--interface))
@@ -285,43 +283,30 @@ Optional:
- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW
- `virtual_device` (Block Set) Virtual device (see [below for nested schema](#nestedblock--z_side--access_point--virtual_device))
-
-### Nested Schema for `z_side.access_point.account`
-
-Optional:
-
-- `account_name` (String) Account Name
-- `account_number` (Number) Account Number
-- `global_cust_id` (String) Global Customer organization identifier
-- `global_org_id` (String) Global organization identifier
-- `global_organization_name` (String) Global organization name
-- `org_id` (Number) Customer organization identifier
-- `organization_name` (String) Customer organization name
+Read-Only:
+- `account` (Set of Object) Account (see [below for nested schema](#nestedatt--z_side--access_point--account))
### Nested Schema for `z_side.access_point.gateway`
Optional:
-- `project` (Block Set) Project this gateway created in (see [below for nested schema](#nestedblock--z_side--access_point--gateway--project))
+- `href` (String) Unique Resource Identifier
- `uuid` (String) Equinix-assigned virtual gateway identifier
Read-Only:
-- `href` (String) Unique Resource Identifier
+- `project` (Set of Object) Project in which this gateway is created (see [below for nested schema](#nestedatt--z_side--access_point--gateway--project))
- `state` (String) Virtual Gateway state
-
+
### Nested Schema for `z_side.access_point.gateway.project`
-Optional:
-
-- `project_id` (String) Project Id
-
Read-Only:
-- `href` (String) Unique Resource URL
+- `href` (String)
+- `project_id` (String)
@@ -365,37 +350,37 @@ Optional:
Optional:
-- `name` (String) Port name
-- `redundancy` (Block Set) Redundancy Information (see [below for nested schema](#nestedblock--z_side--access_point--port--redundancy))
- `uuid` (String) Equinix-assigned Port identifier
Read-Only:
- `href` (String) Unique Resource Identifier
+- `name` (String) Port name
+- `redundancy` (Set of Object) Redundancy Information (see [below for nested schema](#nestedatt--z_side--access_point--port--redundancy))
-
+
### Nested Schema for `z_side.access_point.port.redundancy`
-Optional:
+Read-Only:
-- `priority` (String) Priority type- PRIMARY, SECONDARY
+- `priority` (String)
### Nested Schema for `z_side.access_point.profile`
-Optional:
+Required:
-- `description` (String) User-provided service description
-- `name` (String) Customer-assigned service profile name
- `type` (String) Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE
- `uuid` (String) Equinix assigned service profile identifier
Read-Only:
- `access_point_type_configs` (List of Object) Access point config information (see [below for nested schema](#nestedatt--z_side--access_point--profile--access_point_type_configs))
+- `description` (String) User-provided service description
- `href` (String) Service Profile URI response attribute
+- `name` (String) Customer-assigned service profile name
### Nested Schema for `z_side.access_point.profile.access_point_type_configs`
@@ -430,6 +415,20 @@ Read-Only:
- `href` (String) Unique Resource Identifier
+
+### Nested Schema for `z_side.access_point.account`
+
+Read-Only:
+
+- `account_name` (String)
+- `account_number` (Number)
+- `global_cust_id` (String)
+- `global_org_id` (String)
+- `global_organization_name` (String)
+- `org_id` (Number)
+- `organization_name` (String)
+
+
### Nested Schema for `z_side.additional_info`
@@ -455,20 +454,6 @@ Read-Only:
-
-### Nested Schema for `account`
-
-Optional:
-
-- `account_name` (String) Account Name
-- `account_number` (Number) Account Number
-- `global_cust_id` (String) Global Customer organization identifier
-- `global_org_id` (String) Global organization identifier
-- `global_organization_name` (String) Global organization name
-- `org_id` (Number) Customer organization identifier
-- `organization_name` (String) Customer organization name
-
-
### Nested Schema for `additional_info`
@@ -492,25 +477,16 @@ Read-Only:
- `order_number` (String) Order Reference Number
-
-### Nested Schema for `project`
+
+### Nested Schema for `redundancy`
Optional:
-- `project_id` (String) Project Id
+- `priority` (String) Priority type- PRIMARY, SECONDARY
Read-Only:
-- `href` (String) Unique Resource URL
-
-
-
-### Nested Schema for `redundancy`
-
-Optional:
-
- `group` (String) Redundancy group identifier
-- `priority` (String) Priority type- PRIMARY, SECONDARY
@@ -524,6 +500,20 @@ Optional:
- `update` (String)
+
+### Nested Schema for `account`
+
+Read-Only:
+
+- `account_name` (String)
+- `account_number` (Number)
+- `global_cust_id` (String)
+- `global_org_id` (String)
+- `global_organization_name` (String)
+- `org_id` (Number)
+- `organization_name` (String)
+
+
### Nested Schema for `change_log`
@@ -573,3 +563,12 @@ Read-Only:
- `reason` (String)
+
+
+
+### Nested Schema for `project`
+
+Read-Only:
+
+- `href` (String) Unique Resource URL
+- `project_id` (String) Project Id
diff --git a/docs/resources/equinix_fabric_service_profile.md b/docs/resources/equinix_fabric_service_profile.md
index 80bc97361..1680cca51 100644
--- a/docs/resources/equinix_fabric_service_profile.md
+++ b/docs/resources/equinix_fabric_service_profile.md
@@ -31,7 +31,6 @@ Fabric V4 API compatible resource allows creation and management of Equinix Fabr
- `metros` (Block List) Access point config information (see [below for nested schema](#nestedblock--metros))
- `notifications` (Block List) Preferences for notifications on connection configuration or status changes (see [below for nested schema](#nestedblock--notifications))
- `ports` (Block List) Ports (see [below for nested schema](#nestedblock--ports))
-- `project` (Block Set) Project information (see [below for nested schema](#nestedblock--project))
- `self_profile` (Boolean) Self Profile
- `state` (String) Service profile state - ACTIVE, PENDING_APPROVAL, DELETED, REJECTED
- `tags` (List of String) Tags attached to the connection
@@ -41,9 +40,10 @@ Fabric V4 API compatible resource allows creation and management of Equinix Fabr
### Read-Only
-- `change_log` (Block Set) Captures connection lifecycle change information (see [below for nested schema](#nestedblock--change_log))
+- `change_log` (Set of Object) Captures connection lifecycle change information (see [below for nested schema](#nestedatt--change_log))
- `href` (String) Service Profile URI response attribute
- `id` (String) The ID of this resource.
+- `project` (Set of Object) Project information (see [below for nested schema](#nestedatt--project))
- `uuid` (String) Equinix assigned service profile identifier
@@ -211,18 +211,6 @@ Optional:
-
-### Nested Schema for `project`
-
-Optional:
-
-- `project_id` (String) Project Id
-
-Read-Only:
-
-- `href` (String) Unique Resource URL
-
-
### Nested Schema for `timeouts`
@@ -259,22 +247,29 @@ Optional:
-
+
### Nested Schema for `change_log`
Read-Only:
-- `created_by` (String) Created by User Key
-- `created_by_email` (String) Created by User Email Address
-- `created_by_full_name` (String) Created by User Full Name
-- `created_date_time` (String) Created by Date and Time
-- `deleted_by` (String) Deleted by User Key
-- `deleted_by_email` (String) Deleted by User Email Address
-- `deleted_by_full_name` (String) Deleted by User Full Name
-- `deleted_date_time` (String) Deleted by Date and Time
-- `updated_by` (String) Updated by User Key
-- `updated_by_email` (String) Updated by User Email Address
-- `updated_by_full_name` (String) Updated by User Full Name
-- `updated_date_time` (String) Updated by Date and Time
+- `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 `project`
+Read-Only:
+- `href` (String)
+- `project_id` (String)
diff --git a/equinix/data_source_ecx_l2_sellerprofile.go b/equinix/data_source_ecx_l2_sellerprofile.go
index 8eb859e9a..59b9958a2 100644
--- a/equinix/data_source_ecx_l2_sellerprofile.go
+++ b/equinix/data_source_ecx_l2_sellerprofile.go
@@ -76,8 +76,8 @@ var ecxL2SellerProfileAdditionalInfosDescriptions = map[string]string{
func dataSourceECXL2SellerProfile() *schema.Resource {
return &schema.Resource{
ReadContext: dataSourceECXL2SellerProfileRead,
- Description: "Use this data source to get details of Equinix Fabric layer 2 seller profile with a given name and / or organization",
- Schema: createECXL2SellerProfileSchema(),
+ Description: "Use this data source to get details of Equinix Fabric layer 2 seller profile with a given name and / or organization",
+ Schema: createECXL2SellerProfileSchema(),
}
}
diff --git a/equinix/data_source_fabric_service_profile.go b/equinix/data_source_fabric_service_profile.go
index 497312e95..d31523f30 100755
--- a/equinix/data_source_fabric_service_profile.go
+++ b/equinix/data_source_fabric_service_profile.go
@@ -2,6 +2,7 @@ package equinix
import (
"context"
+
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
diff --git a/equinix/fabric_connection_schema.go b/equinix/fabric_connection_schema.go
index 8d59c9046..2cea9bb09 100755
--- a/equinix/fabric_connection_schema.go
+++ b/equinix/fabric_connection_schema.go
@@ -44,21 +44,25 @@ func createLocationSch() map[string]*schema.Schema {
"region": {
Type: schema.TypeString,
Optional: true,
+ Computed: true,
Description: "Access point region",
},
"metro_name": {
Type: schema.TypeString,
Optional: true,
+ Computed: true,
Description: "Access point metro name",
},
"metro_code": {
Type: schema.TypeString,
Optional: true,
+ Computed: true,
Description: "Access point metro code",
},
"ibx": {
Type: schema.TypeString,
Optional: true,
+ Computed: true,
Description: "IBX Code",
},
}
@@ -73,6 +77,7 @@ func createVirtualGatewaySch() map[string]*schema.Schema {
},
"href": {
Type: schema.TypeString,
+ Optional: true,
Computed: true,
Description: "Unique Resource Identifier",
},
@@ -83,8 +88,8 @@ func createVirtualGatewaySch() map[string]*schema.Schema {
},
"project": {
Type: schema.TypeSet,
- Optional: true,
- Description: "Project this gateway created in",
+ Computed: true,
+ Description: "Project in which this gateway is created",
Elem: &schema.Resource{Schema: createGatewayProjectSch()},
},
}
@@ -98,7 +103,7 @@ func createGatewayProjectSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"project_id": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Project Id",
},
"href": {
@@ -109,6 +114,10 @@ func createGatewayProjectSch() map[string]*schema.Schema {
}
}
+var createServiceProfileSchRes = &schema.Resource{
+ Schema: createServiceProfileSch(),
+}
+
func createServiceProfileSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"href": {
@@ -118,23 +127,23 @@ func createServiceProfileSch() map[string]*schema.Schema {
},
"type": {
Type: schema.TypeString,
- Optional: true,
+ Required: true,
ValidateFunc: validation.StringInSlice([]string{"L2_PROFILE", "L3_PROFILE", "ECIA_PROFILE", "ECMC_PROFILE"}, true),
Description: "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE",
},
"name": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Customer-assigned service profile name",
},
"uuid": {
Type: schema.TypeString,
- Optional: true,
+ Required: true,
Description: "Equinix assigned service profile identifier",
},
"description": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "User-provided service description",
},
"access_point_type_configs": {
@@ -178,16 +187,19 @@ func createAccessPointLinkProtocolSch() map[string]*schema.Schema {
"vlan_tag": {
Type: schema.TypeInt,
Optional: true,
+ Computed: true,
Description: "Vlan Tag information, vlanTag value specified for DOT1Q connections",
},
"vlan_s_tag": {
Type: schema.TypeInt,
Optional: true,
+ Computed: true,
Description: "Vlan Provider Tag information, vlanSTag value specified for QINQ connections",
},
"vlan_c_tag": {
Type: schema.TypeInt,
Optional: true,
+ Computed: true,
Description: "Vlan Customer Tag information, vlanCTag value specified for QINQ connections",
},
}
@@ -266,6 +278,7 @@ func createPortSch() map[string]*schema.Schema {
"uuid": {
Type: schema.TypeString,
Optional: true,
+ Computed: true,
Description: "Equinix-assigned Port identifier",
},
"href": {
@@ -275,12 +288,12 @@ func createPortSch() map[string]*schema.Schema {
},
"name": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Port name",
},
"redundancy": {
Type: schema.TypeSet,
- Optional: true,
+ Computed: true,
Description: "Redundancy Information",
Elem: &schema.Resource{
Schema: createPortRedundancySch(),
@@ -289,140 +302,135 @@ func createPortSch() map[string]*schema.Schema {
}
}
-var createConnectionSideAccessPointRes = &schema.Resource{
- Schema: createConnectionSideAccessPointSch(),
-}
-
-func createConnectionSideAccessPointSch() map[string]*schema.Schema {
- return map[string]*schema.Schema{
- "type": {
- Type: schema.TypeString,
- Optional: true,
- ValidateFunc: validation.StringInSlice([]string{"COLO", "VD", "VG", "SP", "IGW", "SUBNET", "GW"}, true),
- Description: "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW",
- },
- "authentication_key": {
- Type: schema.TypeString,
- Optional: true,
- Description: "Authentication key for provider based connections",
- },
- "account": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Account",
- Elem: &schema.Resource{
- Schema: createAccountSch(),
+func createConnectionSideAccessPointRes() *schema.Resource {
+ return &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "type": {
+ Type: schema.TypeString,
+ Optional: true,
+ ValidateFunc: validation.StringInSlice([]string{"COLO", "VD", "VG", "SP", "IGW", "SUBNET", "GW"}, true),
+ Description: "Access point type - COLO, VD, VG, SP, IGW, SUBNET, GW",
},
- },
- "location": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Access point location",
- Elem: &schema.Resource{
- Schema: createLocationSch(),
+ "authentication_key": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: "Authentication key for provider based connections",
},
- },
- "port": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Port access point information",
- Elem: &schema.Resource{
- Schema: createPortSch(),
+ "account": {
+ Type: schema.TypeSet,
+ Computed: true,
+ Description: "Account",
+ Elem: &schema.Resource{
+ Schema: createAccountSch(),
+ },
},
- },
- "profile": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Service Profile",
- Elem: &schema.Resource{
- Schema: createServiceProfileSch(),
+ "location": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Computed: true,
+ Description: "Access point location",
+ Elem: &schema.Resource{
+ Schema: createLocationSch(),
+ },
},
- },
- "gateway": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Gateway access point information",
- Elem: &schema.Resource{
- Schema: createVirtualGatewaySch(),
+ "port": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Port access point information",
+ Elem: &schema.Resource{
+ Schema: createPortSch(),
+ },
},
- },
- "link_protocol": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Connection link protocol",
- Elem: &schema.Resource{
- Schema: createAccessPointLinkProtocolSch(),
+ "profile": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Service Profile",
+ Elem: &schema.Resource{
+ Schema: createServiceProfileSch(),
+ },
},
- },
- "virtual_device": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Virtual device",
- Elem: &schema.Resource{Schema: createAccessPointVirtualDeviceSch()},
- },
- "interface": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Virtual device interface",
- Elem: &schema.Resource{
- Schema: createAccessPointInterface(),
+ "gateway": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Gateway access point information",
+ Elem: &schema.Resource{
+ Schema: createVirtualGatewaySch(),
+ },
},
- },
- "seller_region": {
- Type: schema.TypeString,
- Optional: true,
- Description: "Access point seller region",
- },
- "peering_type": {
- Type: schema.TypeString,
- Optional: true,
- ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "MICROSOFT", "PUBLIC", "MANUAL"}, true),
- Description: "Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL",
- },
- "routing_protocols": {
- Type: schema.TypeList,
- Optional: true,
- Description: "Access point routing protocols configuration",
- Elem: &schema.Resource{
- Schema: createFabricConnectionRoutingProtocol(),
+ "link_protocol": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Connection link protocol",
+ Elem: &schema.Resource{
+ Schema: createAccessPointLinkProtocolSch(),
+ },
+ },
+ "virtual_device": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Virtual device",
+ Elem: &schema.Resource{Schema: createAccessPointVirtualDeviceSch()},
+ },
+ "interface": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Virtual device interface",
+ Elem: &schema.Resource{
+ Schema: createAccessPointInterface(),
+ },
+ },
+ "seller_region": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: "Access point seller region",
+ },
+ "peering_type": {
+ Type: schema.TypeString,
+ Optional: true,
+ ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "MICROSOFT", "PUBLIC", "MANUAL"}, true),
+ Description: "Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL",
+ },
+ "routing_protocols": {
+ Type: schema.TypeList,
+ Optional: true,
+ Description: "Access point routing protocols configuration",
+ Elem: &schema.Resource{
+ Schema: createFabricConnectionRoutingProtocol(),
+ },
+ },
+ "provider_connection_id": {
+ Type: schema.TypeString,
+ Optional: true,
+ Description: "Provider assigned Connection Id",
},
- },
- "provider_connection_id": {
- Type: schema.TypeString,
- Optional: true,
- Description: "Provider assigned Connection Id",
},
}
}
-var createFabricConnectionSideRes = &schema.Resource{
- Schema: createFabricConnectionSideSch(),
-}
-
-func createFabricConnectionSideSch() map[string]*schema.Schema {
- return map[string]*schema.Schema{
- "service_token": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets",
- Elem: &schema.Resource{
- Schema: createServiceTokenSch(),
+func createFabricConnectionSideRes() *schema.Resource {
+ return &schema.Resource{
+ Schema: map[string]*schema.Schema{
+ "service_token": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "For service token based connections, Service tokens authorize users to access protected resources and services. Resource owners can distribute the tokens to trusted partners and vendors, allowing selected third parties to work directly with Equinix network assets",
+ Elem: &schema.Resource{
+ Schema: createServiceTokenSch(),
+ },
},
- },
- "access_point": {
- Type: schema.TypeSet,
- Optional: true,
- Description: "Point of access details",
- Elem: &schema.Resource{
- Schema: createConnectionSideAccessPointSch(),
+ "access_point": {
+ Type: schema.TypeSet,
+ Optional: true,
+ Description: "Point of access details",
+ Elem: createConnectionSideAccessPointRes(),
},
- },
- "additional_info": {
- Type: schema.TypeList,
- Optional: true,
- Description: "Connection side additional information",
- Elem: &schema.Resource{
- Schema: createAdditionalInfoSch(),
+ "additional_info": {
+ Type: schema.TypeList,
+ Optional: true,
+ Description: "Connection side additional information",
+ Elem: &schema.Resource{
+ Schema: createAdditionalInfoSch(),
+ },
},
},
}
@@ -436,7 +444,7 @@ func createRedundancySch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"group": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Redundancy group identifier",
},
"priority": {
@@ -455,10 +463,9 @@ var createPortRedundancyRes = &schema.Resource{
func createPortRedundancySch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"priority": {
- Type: schema.TypeString,
- Optional: true,
- ValidateFunc: validation.StringInSlice([]string{"PRIMARY", "SECONDARY"}, true),
- Description: "Priority type- PRIMARY, SECONDARY",
+ Type: schema.TypeString,
+ Computed: true,
+ Description: "Priority type- PRIMARY, SECONDARY",
},
}
}
@@ -569,37 +576,37 @@ func createAccountSch() map[string]*schema.Schema {
return map[string]*schema.Schema{
"account_number": {
Type: schema.TypeInt,
- Optional: true,
+ Computed: true,
Description: "Account Number",
},
"account_name": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Account Name",
},
"org_id": {
Type: schema.TypeInt,
- Optional: true,
+ Computed: true,
Description: "Customer organization identifier",
},
"organization_name": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Customer organization name",
},
"global_org_id": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Global organization identifier",
},
"global_organization_name": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Global organization name",
},
"global_cust_id": {
Type: schema.TypeString,
- Optional: true,
+ Computed: true,
Description: "Global Customer organization identifier",
},
}
@@ -735,11 +742,12 @@ func createFabricConnectionResourceSchema() map[string]*schema.Schema {
Required: true,
Description: "Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores",
},
- "description": {
- Type: schema.TypeString,
- Optional: true,
- Description: "Customer-provided connection description",
- },
+ // TODO v4.ConnectionPostRequest doesn't have a description field
+ // "description": {
+ // Type: schema.TypeString,
+ // Optional: true,
+ // Description: "Customer-provided connection description",
+ // },
"type": {
Type: schema.TypeString,
Required: true,
@@ -803,7 +811,7 @@ func createFabricConnectionResourceSchema() map[string]*schema.Schema {
},
"account": {
Type: schema.TypeSet,
- Optional: true,
+ Computed: true,
Description: "Customer account information that is associated with this connection",
Elem: &schema.Resource{
Schema: createAccountSch(),
@@ -834,17 +842,15 @@ func createFabricConnectionResourceSchema() map[string]*schema.Schema {
Type: schema.TypeSet,
Required: true,
Description: "Requester or Customer side connection configuration object of the multi-segment connection",
- Elem: &schema.Resource{
- Schema: createFabricConnectionSideSch(),
- },
+ Elem: createFabricConnectionSideRes(),
+ Set: schema.HashResource(createConnectionSideAccessPointRes()),
},
"z_side": {
Type: schema.TypeSet,
Required: true,
Description: "Destination or Provider side connection configuration object of the multi-segment connection",
- Elem: &schema.Resource{
- Schema: createFabricConnectionSideSch(),
- },
+ Elem: createFabricConnectionSideRes(),
+ Set: schema.HashResource(createConnectionSideAccessPointRes()),
},
}
}
diff --git a/equinix/fabric_mapping_helper.go b/equinix/fabric_mapping_helper.go
index 16588d487..96cfe790d 100644
--- a/equinix/fabric_mapping_helper.go
+++ b/equinix/fabric_mapping_helper.go
@@ -14,8 +14,8 @@ func serviceTokenToFabric(serviceTokenRequest []interface{}) v4.ServiceToken {
mappedST := v4.ServiceToken{}
for _, str := range serviceTokenRequest {
stMap := str.(map[string]interface{})
- stType := stMap["type"].(interface{}).(string)
- uuid := stMap["uuid"].(interface{}).(string)
+ stType := stMap["type"].(string)
+ uuid := stMap["uuid"].(string)
stTypeObj := v4.ServiceTokenType(stType)
mappedST = v4.ServiceToken{Type_: &stTypeObj, Uuid: uuid}
}
@@ -26,8 +26,8 @@ func additionalInfoToFabric(additionalInfoRequest []interface{}) []v4.Connection
var mappedaiArray []v4.ConnectionSideAdditionalInfo
for i, ai := range additionalInfoRequest {
aiMap := ai.(map[string]interface{})
- key := aiMap["key"].(interface{}).(string)
- value := aiMap["value"].(interface{}).(string)
+ key := aiMap["key"].(string)
+ value := aiMap["value"].(string)
mappedai := v4.ConnectionSideAdditionalInfo{Key: key, Value: value}
mappedaiArray[i] = mappedai
}
@@ -38,29 +38,28 @@ func accessPointToFabric(accessPointRequest []interface{}) v4.AccessPoint {
accessPoint := v4.AccessPoint{}
for _, ap := range accessPointRequest {
accessPointMap := ap.(map[string]interface{})
- portList := accessPointMap["port"].(interface{}).(*schema.Set).List()
- profileList := accessPointMap["profile"].(interface{}).(*schema.Set).List()
- locationList := accessPointMap["location"].(interface{}).(*schema.Set).List()
- typeVal := accessPointMap["type"].(interface{}).(string)
- authenticationKey := accessPointMap["authentication_key"].(interface{}).(string)
+ portList := accessPointMap["port"].(*schema.Set).List()
+ profileList := accessPointMap["profile"].(*schema.Set).List()
+ locationList := accessPointMap["location"].(*schema.Set).List()
+ typeVal := accessPointMap["type"].(string)
+ authenticationKey := accessPointMap["authentication_key"].(string)
if authenticationKey != "" {
accessPoint.AuthenticationKey = authenticationKey
-
}
- providerConnectionId := accessPointMap["provider_connection_id"].(interface{}).(string)
+ providerConnectionId := accessPointMap["provider_connection_id"].(string)
if providerConnectionId != "" {
accessPoint.ProviderConnectionId = providerConnectionId
}
- sellerRegion := accessPointMap["seller_region"].(interface{}).(string)
+ sellerRegion := accessPointMap["seller_region"].(string)
if sellerRegion != "" {
accessPoint.SellerRegion = sellerRegion
}
- peeringTypeRaw := accessPointMap["peering_type"].(interface{}).(string)
+ peeringTypeRaw := accessPointMap["peering_type"].(string)
if peeringTypeRaw != "" {
peeringType := v4.PeeringType(peeringTypeRaw)
accessPoint.PeeringType = &peeringType
}
- gatewayRequest := accessPointMap["gateway"].(interface{}).(*schema.Set).List()
+ gatewayRequest := accessPointMap["gateway"].(*schema.Set).List()
if len(gatewayRequest) != 0 {
mappedGWr := gatewayToFabric(gatewayRequest)
@@ -76,7 +75,7 @@ func accessPointToFabric(accessPointRequest []interface{}) v4.AccessPoint {
accessPoint.Port = &port
}
}
- linkProtocolList := accessPointMap["link_protocol"].(interface{}).(*schema.Set).List()
+ linkProtocolList := accessPointMap["link_protocol"].(*schema.Set).List()
if len(linkProtocolList) != 0 {
slp := linkProtocolToFabric(linkProtocolList)
@@ -108,22 +107,22 @@ func gatewayToFabric(gatewayRequest []interface{}) v4.VirtualGateway {
gatewayMapped := v4.VirtualGateway{}
for _, gwr := range gatewayRequest {
gwrMap := gwr.(map[string]interface{})
- gwHref := gwrMap["href"].(interface{}).(string)
- gwuuid := gwrMap["uuid"].(interface{}).(string)
+ gwHref := gwrMap["href"].(string)
+ gwuuid := gwrMap["uuid"].(string)
gatewayMapped = v4.VirtualGateway{Uuid: gwuuid, Href: gwHref}
}
return gatewayMapped
}
func projectToFabric(projectRequest []interface{}) v4.Project {
- if projectRequest == nil || len(projectRequest) == 0 {
+ if len(projectRequest) == 0 {
return v4.Project{}
}
mappedPr := v4.Project{}
for _, pr := range projectRequest {
prMap := pr.(map[string]interface{})
- projectId := prMap["project_id"].(interface{}).(string)
- href := prMap["href"].(interface{}).(string)
+ projectId := prMap["project_id"].(string)
+ href := prMap["href"].(string)
mappedPr = v4.Project{ProjectId: projectId, Href: href}
}
return mappedPr
@@ -155,8 +154,7 @@ func redundancyToFabric(schemaRedundancy []interface{}) v4.ConnectionRedundancy
red := v4.ConnectionRedundancy{}
for _, r := range schemaRedundancy {
redundancyMap := r.(map[string]interface{})
- priority := redundancyMap["priority"]
- priorityCont := v4.ConnectionPriority(priority.(string))
+ priorityCont := v4.ConnectionPriority(redundancyMap["priority"].(string))
red = v4.ConnectionRedundancy{
Priority: &priorityCont,
}
@@ -184,10 +182,10 @@ func linkProtocolToFabric(linkProtocolList []interface{}) v4.SimplifiedLinkProto
slp := v4.SimplifiedLinkProtocol{}
for _, lp := range linkProtocolList {
lpMap := lp.(map[string]interface{})
- lpType := lpMap["type"].(interface{}).(string)
- lpVlanSTag := lpMap["vlan_s_tag"].(interface{}).(int)
- lpVlanTag := lpMap["vlan_tag"].(interface{}).(int)
- lpVlanCTag := lpMap["vlan_c_tag"].(interface{}).(int)
+ lpType := lpMap["type"].(string)
+ lpVlanSTag := lpMap["vlan_s_tag"].(int)
+ lpVlanTag := lpMap["vlan_tag"].(int)
+ lpVlanCTag := lpMap["vlan_c_tag"].(int)
lpt := v4.LinkProtocolType(lpType)
slp = v4.SimplifiedLinkProtocol{Type_: &lpt, VlanSTag: int32(lpVlanSTag), VlanTag: int32(lpVlanTag), VlanCTag: int32(lpVlanCTag)}
}
@@ -198,7 +196,7 @@ func portToFabric(portList []interface{}) v4.SimplifiedPort {
p := v4.SimplifiedPort{}
for _, pl := range portList {
plMap := pl.(map[string]interface{})
- uuid := plMap["uuid"].(interface{}).(string)
+ uuid := plMap["uuid"].(string)
p = v4.SimplifiedPort{Uuid: uuid}
}
return p
@@ -208,9 +206,9 @@ func simplifiedServiceProfileToFabric(profileList []interface{}) v4.SimplifiedSe
ssp := v4.SimplifiedServiceProfile{}
for _, pl := range profileList {
plMap := pl.(map[string]interface{})
- ptype := plMap["type"].(interface{}).(string)
+ ptype := plMap["type"].(string)
spte := v4.ServiceProfileTypeEnum(ptype)
- uuid := plMap["uuid"].(interface{}).(string)
+ uuid := plMap["uuid"].(string)
ssp = v4.SimplifiedServiceProfile{Uuid: uuid, Type_: &spte}
}
return ssp
@@ -223,11 +221,11 @@ func locationToFabric(locationList []interface{}) v4.SimplifiedLocation {
metroName := llMap["metro_name"]
var metroNamestr string
if metroName != nil {
- metroNamestr = metroName.(interface{}).(string)
+ metroNamestr = metroName.(string)
}
- region := llMap["region"].(interface{}).(string)
- mc := llMap["metro_code"].(interface{}).(string)
- ibx := llMap["ibx"].(interface{}).(string)
+ region := llMap["region"].(string)
+ mc := llMap["metro_code"].(string)
+ ibx := llMap["ibx"].(string)
sl = v4.SimplifiedLocation{MetroCode: mc, Region: region, Ibx: ibx, MetroName: metroNamestr}
}
return sl
@@ -238,22 +236,23 @@ func accountToTerra(account *v4.SimplifiedAccount) *schema.Set {
return nil
}
accounts := []*v4.SimplifiedAccount{account}
- mappedAccounts := make([]interface{}, 0)
- for _, account := range accounts {
- mappedAccount := make(map[string]interface{})
- mappedAccount["account_number"] = int(account.AccountNumber)
- mappedAccount["account_name"] = account.AccountName
- mappedAccount["org_id"] = int(account.OrgId)
- mappedAccount["organization_name"] = account.OrganizationName
- mappedAccount["global_org_id"] = account.GlobalOrgId
- mappedAccount["global_organization_name"] = account.GlobalOrganizationName
- mappedAccount["global_cust_id"] = account.GlobalCustId
- mappedAccounts = append(mappedAccounts, mappedAccount)
+ mappedAccounts := make([]interface{}, len(accounts))
+ for i, account := range accounts {
+ mappedAccounts[i] = map[string]interface{}{
+ "account_number": int(account.AccountNumber),
+ "account_name": account.AccountName,
+ "org_id": int(account.OrgId),
+ "organization_name": account.OrganizationName,
+ "global_org_id": account.GlobalOrgId,
+ "global_organization_name": account.GlobalOrganizationName,
+ "global_cust_id": account.GlobalCustId,
+ }
}
accountSet := schema.NewSet(
schema.HashResource(createAccountRes),
mappedAccounts,
)
+
return accountSet
}
@@ -294,7 +293,7 @@ func operationToTerra(operation *v4.ConnectionOperation) *schema.Set {
return nil
}
operations := []*v4.ConnectionOperation{operation}
- mappedOperations := make([]interface{}, 0)
+ mappedOperations := make([]interface{}, len(operations))
for _, operation := range operations {
mappedOperation := make(map[string]interface{})
mappedOperation["provider_status"] = string(*operation.ProviderStatus)
@@ -317,7 +316,7 @@ func orderMappingToTerra(order *v4.Order) *schema.Set {
return nil
}
orders := []*v4.Order{order}
- mappedOrders := make([]interface{}, 0)
+ mappedOrders := make([]interface{}, len(orders))
for _, order := range orders {
mappedOrder := make(map[string]interface{})
mappedOrder["purchase_order_number"] = order.PurchaseOrderNumber
@@ -338,7 +337,7 @@ func changeLogToTerra(changeLog *v4.Changelog) *schema.Set {
return nil
}
changeLogs := []*v4.Changelog{changeLog}
- mappedChangeLogs := make([]interface{}, 0)
+ mappedChangeLogs := make([]interface{}, len(changeLogs))
for _, changeLog := range changeLogs {
mappedChangeLog := make(map[string]interface{})
mappedChangeLog["created_by"] = changeLog.CreatedBy
@@ -363,7 +362,7 @@ func changeLogToTerra(changeLog *v4.Changelog) *schema.Set {
func portRedundancyToTerra(redundancy *v4.PortRedundancy) *schema.Set {
redundancies := []*v4.PortRedundancy{redundancy}
- mappedRedundancys := make([]interface{}, 0)
+ mappedRedundancys := make([]interface{}, len(redundancies))
for _, redundancy := range redundancies {
mappedRedundancy := make(map[string]interface{})
mappedRedundancy["priority"] = string(*redundancy.Priority)
@@ -381,7 +380,7 @@ func redundancyToTerra(redundancy *v4.ConnectionRedundancy) *schema.Set {
return nil
}
redundancies := []*v4.ConnectionRedundancy{redundancy}
- mappedRedundancys := make([]interface{}, 0)
+ mappedRedundancys := make([]interface{}, len(redundancies))
for _, redundancy := range redundancies {
mappedRedundancy := make(map[string]interface{})
mappedRedundancy["group"] = redundancy.Group
@@ -412,14 +411,14 @@ func notificationToTerra(notifications []v4.SimplifiedNotification) []map[string
func locationToTerra(location *v4.SimplifiedLocation) *schema.Set {
locations := []*v4.SimplifiedLocation{location}
- mappedLocations := make([]interface{}, 0)
- for _, location := range locations {
- mappedLocation := make(map[string]interface{})
- mappedLocation["region"] = location.Region
- mappedLocation["metro_name"] = location.MetroName
- mappedLocation["metro_code"] = location.MetroCode
- mappedLocation["ibx"] = location.Ibx
- mappedLocations = append(mappedLocations, mappedLocation)
+ mappedLocations := make([]interface{}, len(locations))
+ for i, location := range locations {
+ mappedLocations[i] = map[string]interface{}{
+ "region": location.Region,
+ "metro_name": location.MetroName,
+ "metro_code": location.MetroCode,
+ "ibx": location.Ibx,
+ }
}
locationSet := schema.NewSet(
schema.HashResource(createLocationRes),
@@ -433,7 +432,7 @@ func serviceTokenToTerra(serviceToken *v4.ServiceToken) *schema.Set {
return nil
}
serviceTokens := []*v4.ServiceToken{serviceToken}
- mappedServiceTokens := make([]interface{}, 0)
+ mappedServiceTokens := make([]interface{}, len(serviceTokens))
for _, serviceToken := range serviceTokens {
mappedServiceToken := make(map[string]interface{})
if serviceToken.Type_ != nil {
@@ -441,7 +440,6 @@ func serviceTokenToTerra(serviceToken *v4.ServiceToken) *schema.Set {
}
mappedServiceToken["href"] = serviceToken.Href
mappedServiceToken["uuid"] = serviceToken.Uuid
- mappedServiceToken["description"] = serviceToken.Description
mappedServiceTokens = append(mappedServiceTokens, mappedServiceToken)
}
serviceTokenSet := schema.NewSet(
@@ -453,7 +451,7 @@ func serviceTokenToTerra(serviceToken *v4.ServiceToken) *schema.Set {
func connectionSideToTerra(connectionSide *v4.ConnectionSide) *schema.Set {
connectionSides := []*v4.ConnectionSide{connectionSide}
- mappedConnectionSides := make([]interface{}, 0)
+ mappedConnectionSides := make([]interface{}, len(connectionSides))
for _, connectionSide := range connectionSides {
mappedConnectionSide := make(map[string]interface{})
serviceTokenSet := serviceTokenToTerra(connectionSide.ServiceToken)
@@ -464,7 +462,7 @@ func connectionSideToTerra(connectionSide *v4.ConnectionSide) *schema.Set {
mappedConnectionSides = append(mappedConnectionSides, mappedConnectionSide)
}
connectionSideSet := schema.NewSet(
- schema.HashResource(createFabricConnectionSideRes),
+ schema.HashResource(createFabricConnectionSideRes()),
mappedConnectionSides,
)
return connectionSideSet
@@ -489,7 +487,7 @@ func fabricGatewayToTerra(virtualGateway *v4.VirtualGateway) *schema.Set {
return nil
}
virtualGateways := []*v4.VirtualGateway{virtualGateway}
- mappedvirtualGateways := make([]interface{}, 0)
+ mappedvirtualGateways := make([]interface{}, len(virtualGateways))
for _, virtualGateway := range virtualGateways {
mappedvirtualGateway := make(map[string]interface{})
mappedvirtualGateway["uuid"] = virtualGateway.Uuid
@@ -507,7 +505,7 @@ func projectToTerra(project *v4.Project) *schema.Set {
return nil
}
projects := []*v4.Project{project}
- mappedProjects := make([]interface{}, 0)
+ mappedProjects := make([]interface{}, len(projects))
for _, project := range projects {
mappedProject := make(map[string]interface{})
mappedProject["project_id"] = project.ProjectId
@@ -525,7 +523,7 @@ func virtualDeviceToTerra(virtualDevice *v4.VirtualDevice) *schema.Set {
return nil
}
virtualDevices := []*v4.VirtualDevice{virtualDevice}
- mappedVirtualDevices := make([]interface{}, 0)
+ mappedVirtualDevices := make([]interface{}, len(virtualDevices))
for _, virtualDevice := range virtualDevices {
mappedVirtualDevice := make(map[string]interface{})
mappedVirtualDevice["name"] = virtualDevice.Name
@@ -545,7 +543,7 @@ func interfaceToTerra(mInterface *v4.ModelInterface) *schema.Set {
return nil
}
mInterfaces := []*v4.ModelInterface{mInterface}
- mappedMInterfaces := make([]interface{}, 0)
+ mappedMInterfaces := make([]interface{}, len(mInterfaces))
for _, mInterface := range mInterfaces {
mappedMInterface := make(map[string]interface{})
mappedMInterface["id"] = mInterface.Id
@@ -561,7 +559,7 @@ func interfaceToTerra(mInterface *v4.ModelInterface) *schema.Set {
func accessPointToTerra(accessPoint *v4.AccessPoint) *schema.Set {
accessPoints := []*v4.AccessPoint{accessPoint}
- mappedAccessPoints := make([]interface{}, 0)
+ mappedAccessPoints := make([]interface{}, len(accessPoints))
for _, accessPoint := range accessPoints {
mappedAccessPoint := make(map[string]interface{})
if accessPoint.Type_ != nil {
@@ -573,22 +571,18 @@ func accessPointToTerra(accessPoint *v4.AccessPoint) *schema.Set {
if accessPoint.Location != nil {
mappedAccessPoint["location"] = locationToTerra(accessPoint.Location)
}
-
if accessPoint.Port != nil {
mappedAccessPoint["port"] = portToTerra(accessPoint.Port)
}
if accessPoint.Profile != nil {
mappedAccessPoint["profile"] = simplifiedServiceProfileToTerra(accessPoint.Profile)
}
-
if accessPoint.Gateway != nil {
mappedAccessPoint["gateway"] = fabricGatewayToTerra(accessPoint.Gateway)
}
-
if accessPoint.LinkProtocol != nil {
- mappedAccessPoint["link_protocol"] = linkedProtocolToTerra(accessPoint.LinkProtocol)
+ mappedAccessPoint["link_protocol"] = linkedProtocolToTerra(*accessPoint.LinkProtocol)
}
-
if accessPoint.VirtualDevice != nil {
mappedAccessPoint["virtual_device"] = virtualDeviceToTerra(accessPoint.VirtualDevice)
}
@@ -604,15 +598,15 @@ func accessPointToTerra(accessPoint *v4.AccessPoint) *schema.Set {
mappedAccessPoints = append(mappedAccessPoints, mappedAccessPoint)
}
accessPointSet := schema.NewSet(
- schema.HashResource(createConnectionSideAccessPointRes),
+ schema.HashResource(createConnectionSideAccessPointRes()),
mappedAccessPoints,
)
return accessPointSet
}
-func linkedProtocolToTerra(linkedProtocol *v4.SimplifiedLinkProtocol) *schema.Set {
- linkedProtocols := []*v4.SimplifiedLinkProtocol{linkedProtocol}
- mappedLinkedProtocols := make([]interface{}, 0)
+func linkedProtocolToTerra(linkedProtocol v4.SimplifiedLinkProtocol) *schema.Set {
+ linkedProtocols := []v4.SimplifiedLinkProtocol{linkedProtocol}
+ mappedLinkedProtocols := make([]interface{}, len(linkedProtocols))
for _, linkedProtocol := range linkedProtocols {
mappedLinkedProtocol := make(map[string]interface{})
mappedLinkedProtocol["type"] = string(*linkedProtocol.Type_)
@@ -629,7 +623,7 @@ func linkedProtocolToTerra(linkedProtocol *v4.SimplifiedLinkProtocol) *schema.Se
func simplifiedServiceProfileToTerra(profile *v4.SimplifiedServiceProfile) *schema.Set {
profiles := []*v4.SimplifiedServiceProfile{profile}
- mappedProfiles := make([]interface{}, 0)
+ mappedProfiles := make([]interface{}, len(profiles))
for _, profile := range profiles {
mappedProfile := make(map[string]interface{})
mappedProfile["href"] = profile.Href
@@ -639,8 +633,9 @@ func simplifiedServiceProfileToTerra(profile *v4.SimplifiedServiceProfile) *sche
mappedProfile["access_point_type_configs"] = accessPointTypeConfigToTerra(profile.AccessPointTypeConfigs)
mappedProfiles = append(mappedProfiles, mappedProfile)
}
+
profileSet := schema.NewSet(
- schema.HashResource(createLocationRes),
+ schema.HashResource(createServiceProfileSchRes),
mappedProfiles,
)
return profileSet
@@ -663,12 +658,13 @@ func accessPointTypeConfigToTerra(spAccessPointTypes []v4.ServiceProfileAccessPo
"supported_bandwidths": supportedBandwidthsToTerra(spAccessPointType.SupportedBandwidths),
}
}
+
return mappedSpAccessPointTypes
}
func apiConfigToTerra(apiConfig *v4.ApiConfig) *schema.Set {
apiConfigs := []*v4.ApiConfig{apiConfig}
- mappedApiConfigs := make([]interface{}, 0)
+ mappedApiConfigs := make([]interface{}, len(apiConfigs))
for _, apiConfig := range apiConfigs {
mappedApiConfig := make(map[string]interface{})
mappedApiConfig["api_available"] = apiConfig.ApiAvailable
@@ -686,7 +682,7 @@ func apiConfigToTerra(apiConfig *v4.ApiConfig) *schema.Set {
func authenticationKeyToTerra(authenticationKey *v4.AuthenticationKey) *schema.Set {
authenticationKeys := []*v4.AuthenticationKey{authenticationKey}
- mappedAuthenticationKeys := make([]interface{}, 0)
+ mappedAuthenticationKeys := make([]interface{}, len(authenticationKeys))
for _, authenticationKey := range authenticationKeys {
mappedAuthenticationKey := make(map[string]interface{})
mappedAuthenticationKey["required"] = authenticationKey.Required
@@ -704,7 +700,7 @@ func supportedBandwidthsToTerra(supportedBandwidths *[]int32) []interface{} {
if supportedBandwidths == nil {
return nil
}
- mappedSupportedBandwidths := make([]interface{}, 0)
+ mappedSupportedBandwidths := make([]interface{}, len(*supportedBandwidths))
for _, bandwidth := range *supportedBandwidths {
mappedSupportedBandwidths = append(mappedSupportedBandwidths, int(bandwidth))
}
@@ -713,7 +709,7 @@ func supportedBandwidthsToTerra(supportedBandwidths *[]int32) []interface{} {
func portToTerra(port *v4.SimplifiedPort) *schema.Set {
ports := []*v4.SimplifiedPort{port}
- mappedPorts := make([]interface{}, 0)
+ mappedPorts := make([]interface{}, len(ports))
for _, port := range ports {
mappedPort := make(map[string]interface{})
mappedPort["href"] = port.Href
@@ -746,7 +742,7 @@ func getUpdateRequest(conn v4.Connection, d *schema.ResourceData) (v4.Connection
} else if existingBandwidth != updateBandwidthVal {
changeOps = v4.ConnectionChangeOperation{Op: "replace", Path: "/bandwidth", Value: updateBandwidthVal}
} else {
- return changeOps, fmt.Errorf("Nothing to update for the connection %s", existingName)
+ return changeOps, fmt.Errorf("nothing to update for the connection %s", existingName)
}
return changeOps, nil
}
diff --git a/equinix/fabric_mapping_service_profile_helper.go b/equinix/fabric_mapping_service_profile_helper.go
index 3b662164a..acda6a6c2 100644
--- a/equinix/fabric_mapping_service_profile_helper.go
+++ b/equinix/fabric_mapping_service_profile_helper.go
@@ -404,7 +404,7 @@ func metrosToFabric(schemaMetros []interface{}) []v4.ServiceMetro {
}
func fabricServiceProfilesListToTerra(serviceProfiles v4.ServiceProfiles) []map[string]interface{} {
- var serviceProfile = serviceProfiles.Data
+ serviceProfile := serviceProfiles.Data
if serviceProfile == nil {
return nil
}
diff --git a/equinix/fabric_port_mapping_helper.go b/equinix/fabric_port_mapping_helper.go
index 0b32c930f..ceac6d01e 100644
--- a/equinix/fabric_port_mapping_helper.go
+++ b/equinix/fabric_port_mapping_helper.go
@@ -126,7 +126,7 @@ func lagToTerra(portLag *v4.PortLag) *schema.Set {
}
func fabricPortsListToTerra(ports v4.AllPortsResponse) []map[string]interface{} {
- var portsl = ports.Data
+ portsl := ports.Data
if portsl == nil {
return nil
}
diff --git a/equinix/fabric_service_profile_schema.go b/equinix/fabric_service_profile_schema.go
index d6b93b47d..d6d9062c4 100755
--- a/equinix/fabric_service_profile_schema.go
+++ b/equinix/fabric_service_profile_schema.go
@@ -134,7 +134,7 @@ func createFabricServiceProfileSchema() map[string]*schema.Schema {
},
"change_log": {
Type: schema.TypeSet,
- Optional: true,
+ Computed: true,
Description: "Captures connection lifecycle change information",
Elem: &schema.Resource{
Schema: createChangeLogSch(),
diff --git a/equinix/fabric_service_profile_search_schema.go b/equinix/fabric_service_profile_search_schema.go
index a05240f41..c0c7a46c9 100755
--- a/equinix/fabric_service_profile_search_schema.go
+++ b/equinix/fabric_service_profile_search_schema.go
@@ -34,11 +34,13 @@ func createServiceProfilesSearchSortCriteriaSch() map[string]*schema.Schema {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"DESC", "ASC"}, true),
- Description: "Priority type- DESC, ASC"},
+ Description: "Priority type- DESC, ASC",
+ },
"property": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"/name", "/state", "/changeLog/createdDateTime", "/changeLog/updatedDateTime"}, true),
- Description: "Search operation sort criteria /name /state /changeLog/createdDateTime /changeLog/updatedDateTime"},
+ Description: "Search operation sort criteria /name /state /changeLog/createdDateTime /changeLog/updatedDateTime",
+ },
}
}
diff --git a/equinix/provider.go b/equinix/provider.go
index e4f3012b8..726f739e6 100644
--- a/equinix/provider.go
+++ b/equinix/provider.go
@@ -9,6 +9,7 @@ import (
"strings"
"time"
+ v4 "github.com/equinix-labs/fabric-go/fabric/v4"
"github.com/equinix/ecx-go/v2"
"github.com/equinix/rest-go"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -256,6 +257,15 @@ func hasApplicationErrorCode(errors []rest.ApplicationError, code string) bool {
return false
}
+func hasModelErrorCode(errors []v4.ModelError, code string) bool {
+ for _, err := range errors {
+ if err.ErrorCode == code {
+ return true
+ }
+ }
+ return false
+}
+
func stringIsMetroCode() schema.SchemaValidateFunc {
return validation.StringMatch(regexp.MustCompile("^[A-Z]{2}$"), "MetroCode must consist of two capital letters")
}
diff --git a/equinix/resource_fabric_connection.go b/equinix/resource_fabric_connection.go
index 04f531ad3..45a24db7e 100755
--- a/equinix/resource_fabric_connection.go
+++ b/equinix/resource_fabric_connection.go
@@ -40,18 +40,18 @@ func resourceFabricConnectionCreate(ctx context.Context, d *schema.ResourceData,
conType := v4.ConnectionType(d.Get("type").(string))
schemaNotifications := d.Get("notifications").([]interface{})
notifications := notificationToFabric(schemaNotifications)
- schemaRedundancy := d.Get("redundancy").(interface{}).(*schema.Set).List()
+ schemaRedundancy := d.Get("redundancy").(*schema.Set).List()
red := redundancyToFabric(schemaRedundancy)
- schemaOrder := d.Get("order").(interface{}).(*schema.Set).List()
+ schemaOrder := d.Get("order").(*schema.Set).List()
order := orderToFabric(schemaOrder)
- aside := d.Get("a_side").(interface{}).(*schema.Set).List()
- projectReq := d.Get("project").(interface{}).(*schema.Set).List()
+ aside := d.Get("a_side").(*schema.Set).List()
+ projectReq := d.Get("project").(*schema.Set).List()
project := projectToFabric(projectReq)
connectionASide := v4.ConnectionSide{}
for _, as := range aside {
asideMap := as.(map[string]interface{})
- accessPoint := asideMap["access_point"].(interface{}).(*schema.Set).List()
- serviceTokenRequest := asideMap["service_token"].(interface{}).(*schema.Set).List()
+ accessPoint := asideMap["access_point"].(*schema.Set).List()
+ serviceTokenRequest := asideMap["service_token"].(*schema.Set).List()
additionalInfoRequest := asideMap["additional_info"].([]interface{})
if len(accessPoint) != 0 {
@@ -68,12 +68,12 @@ func resourceFabricConnectionCreate(ctx context.Context, d *schema.ResourceData,
}
}
- zside := d.Get("z_side").(interface{}).(*schema.Set).List()
+ zside := d.Get("z_side").(*schema.Set).List()
connectionZSide := v4.ConnectionSide{}
for _, as := range zside {
zsideMap := as.(map[string]interface{})
- accessPoint := zsideMap["access_point"].(interface{}).(*schema.Set).List()
- serviceTokenRequest := zsideMap["service_token"].(interface{}).(*schema.Set).List()
+ accessPoint := zsideMap["access_point"].(*schema.Set).List()
+ serviceTokenRequest := zsideMap["service_token"].(*schema.Set).List()
additionalInfoRequest := zsideMap["additional_info"].([]interface{})
if len(accessPoint) != 0 {
ap := accessPointToFabric(accessPoint)
@@ -106,6 +106,11 @@ func resourceFabricConnectionCreate(ctx context.Context, d *schema.ResourceData,
return diag.FromErr(err)
}
d.SetId(conn.Uuid)
+
+ if err = waitUntilConnectionIsProvisioned(d.Id(), meta, ctx); err != nil {
+ return diag.Errorf("error waiting for connection (%s) to be created: %s", d.Id(), err)
+ }
+
return resourceFabricConnectionRead(ctx, d, meta)
}
@@ -127,10 +132,12 @@ func resourceFabricConnectionRead(ctx context.Context, d *schema.ResourceData, m
func setFabricMap(d *schema.ResourceData, conn v4.Connection) diag.Diagnostics {
diags := diag.Diagnostics{}
err := setMap(d, map[string]interface{}{
- "name": conn.Name,
- "bandwidth": conn.Bandwidth,
- "href": conn.Href,
- "description": conn.Description,
+ "name": conn.Name,
+ "bandwidth": conn.Bandwidth,
+ "href": conn.Href,
+ // TODO v4.ConnectionPostRequest doesn't have a "description" field,
+ // so it always returns empty because it was never in the API, that produces an inconsistency
+ // "description": conn.Description,
"is_remote": conn.IsRemote,
"type": conn.Type_,
"state": conn.State,
@@ -155,36 +162,30 @@ func setFabricMap(d *schema.ResourceData, conn v4.Connection) diag.Diagnostics {
func resourceFabricConnectionUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*Config).fabricClient
ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*Config).FabricAuthToken)
- uuid := d.Id()
- if uuid == "" {
- return diag.Errorf("No connection found for the value uuid %v ", uuid)
- }
- dbConn := v4.Connection{}
- var err error
- dbConn, err = waitUntilConnectionIsActive(uuid, meta, ctx)
+ dbConn, err := waitUntilConnectionIsActive(d.Id(), meta, ctx)
if err != nil {
if !strings.Contains(err.Error(), "500") {
d.SetId("")
}
- return diag.Errorf(" Either timed out or errored out while fetching connection for uuid %s and error %v", uuid, err)
+ return diag.Errorf("either timed out or errored out while fetching connection for uuid %s and error %v", d.Id(), err)
}
update, err := getUpdateRequest(dbConn, d)
if err != nil {
return diag.FromErr(err)
}
updates := []v4.ConnectionChangeOperation{update}
- _, res, err := client.ConnectionsApi.UpdateConnectionByUuid(ctx, updates, uuid)
+ _, res, err := client.ConnectionsApi.UpdateConnectionByUuid(ctx, updates, d.Id())
if err != nil {
- return diag.FromErr(fmt.Errorf("Error response for the connection update, response %v, error %v", res, err))
+ return diag.FromErr(fmt.Errorf("error response for the connection update, response %v, error %v", res, err))
}
updatedConn := v4.Connection{}
- updatedConn, err = waitForConnectionUpdateCompletion(uuid, meta, ctx)
+ updatedConn, err = waitForConnectionUpdateCompletion(d.Id(), meta, ctx)
if err != nil {
if !strings.Contains(err.Error(), "500") {
d.SetId("")
}
- return diag.FromErr(fmt.Errorf("Errored while waiting for successful connection update, response %v, error %v", res, err))
+ return diag.FromErr(fmt.Errorf("errored while waiting for successful connection update, response %v, error %v", res, err))
}
d.SetId(updatedConn.Uuid)
@@ -202,7 +203,7 @@ func waitForConnectionUpdateCompletion(uuid string, meta interface{}, ctx contex
return "", "", err
}
updatableState := ""
- if "COMPLETED" == dbConn.Change.Status {
+ if dbConn.Change.Status == "COMPLETED" {
updatableState = dbConn.Change.Status
}
return dbConn, updatableState, nil
@@ -221,10 +222,41 @@ func waitForConnectionUpdateCompletion(uuid string, meta interface{}, ctx contex
return dbConn, err
}
+func waitUntilConnectionIsProvisioned(uuid string, meta interface{}, ctx context.Context) error {
+ log.Printf("Waiting for connection to be provisioned, uuid %s", uuid)
+ stateConf := &resource.StateChangeConf{
+ Pending: []string{
+ string(v4.PROVISIONING_ConnectionState),
+ },
+ Target: []string{
+ string(v4.PENDING_ConnectionState),
+ string(v4.PROVISIONED_ConnectionState),
+ string(v4.ACTIVE_ConnectionState),
+ },
+ Refresh: func() (interface{}, string, error) {
+ client := meta.(*Config).fabricClient
+ dbConn, _, err := client.ConnectionsApi.GetConnectionByUuid(ctx, uuid, nil)
+ if err != nil {
+ return "", "", err
+ }
+ return dbConn, string(*dbConn.State), nil
+ },
+ Timeout: 5 * time.Minute,
+ Delay: 30 * time.Second,
+ MinTimeout: 30 * time.Second,
+ }
+
+ _, err := stateConf.WaitForStateContext(ctx)
+
+ return err
+}
+
func waitUntilConnectionIsActive(uuid string, meta interface{}, ctx context.Context) (v4.Connection, error) {
log.Printf("Waiting for connection to be in active state, uuid %s", uuid)
stateConf := &resource.StateChangeConf{
- Target: []string{"ACTIVE"},
+ Target: []string{
+ string(v4.ACTIVE_ConnectionState),
+ },
Refresh: func() (interface{}, string, error) {
client := meta.(*Config).fabricClient
dbConn, _, err := client.ConnectionsApi.GetConnectionByUuid(ctx, uuid, nil)
@@ -232,7 +264,7 @@ func waitUntilConnectionIsActive(uuid string, meta interface{}, ctx context.Cont
return "", "", err
}
updatableState := ""
- if "ACTIVE" == *dbConn.State {
+ if *dbConn.State == v4.ACTIVE_ConnectionState {
updatableState = string(*dbConn.State)
}
return dbConn, updatableState, nil
@@ -255,14 +287,47 @@ func resourceFabricConnectionDelete(ctx context.Context, d *schema.ResourceData,
diags := diag.Diagnostics{}
client := meta.(*Config).fabricClient
ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*Config).FabricAuthToken)
- uuid := d.Id()
- if uuid == "" {
- return diag.Errorf("No uuid found %v ", uuid)
+ _, resp, err := client.ConnectionsApi.DeleteConnectionByUuid(ctx, d.Id())
+ if err != nil {
+ errors, ok := err.(v4.GenericSwaggerError).Model().([]v4.ModelError)
+ if ok {
+ // EQ-3142509 = Connection already deleted
+ if hasModelErrorCode(errors, "EQ-3142509") {
+ return diags
+ }
+ }
+ return diag.FromErr(fmt.Errorf("error response for the connection delete. Error %v and response %v", err, resp))
}
- _, resp, err := client.ConnectionsApi.DeleteConnectionByUuid(ctx, uuid)
+
+ err = waitUntilConnectionDeprovisioned(d.Id(), meta, ctx)
if err != nil {
- fmt.Errorf("Error response for the connection delete error %v and response %v", err, resp)
- return diag.FromErr(err)
+ return diag.FromErr(fmt.Errorf("API call failed while waiting for resource deletion. Error %v", err))
}
return diags
}
+
+func waitUntilConnectionDeprovisioned(uuid string, meta interface{}, ctx context.Context) error {
+ log.Printf("Waiting for connection to be deprovisioned, uuid %s", uuid)
+ stateConf := &resource.StateChangeConf{
+ Pending: []string{
+ string(v4.DEPROVISIONING_ConnectionState),
+ },
+ Target: []string{
+ string(v4.DEPROVISIONED_ConnectionState),
+ },
+ Refresh: func() (interface{}, string, error) {
+ client := meta.(*Config).fabricClient
+ dbConn, _, err := client.ConnectionsApi.GetConnectionByUuid(ctx, uuid, nil)
+ if err != nil {
+ return "", "", err
+ }
+ return dbConn, string(*dbConn.State), nil
+ },
+ Timeout: 5 * time.Minute,
+ Delay: 30 * time.Second,
+ MinTimeout: 30 * time.Second,
+ }
+
+ _, err := stateConf.WaitForStateContext(ctx)
+ return err
+}
diff --git a/equinix/resource_fabric_connection_acc_test.go b/equinix/resource_fabric_connection_acc_test.go
index 7e93a4537..efa8a6375 100755
--- a/equinix/resource_fabric_connection_acc_test.go
+++ b/equinix/resource_fabric_connection_acc_test.go
@@ -3,9 +3,7 @@ package equinix
import (
"context"
"fmt"
- "log"
"testing"
- "time"
v4 "github.com/equinix-labs/fabric-go/fabric/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
@@ -43,14 +41,13 @@ func TestAccFabricCreateConnection(t *testing.T) {
}
func checkConnectionDelete(s *terraform.State) error {
- client := testAccProvider.Meta().(*Config).fabricClient
ctx := context.Background()
ctx = context.WithValue(ctx, v4.ContextAccessToken, testAccProvider.Meta().(*Config).FabricAuthToken)
for _, rs := range s.RootModule().Resources {
if rs.Type != "equinix_fabric_connection" {
continue
}
- _, err := waitUntilConnectionDeprovisioned(rs.Primary.ID, client, ctx)
+ err := waitUntilConnectionDeprovisioned(rs.Primary.ID, testAccProvider.Meta(), ctx)
if err != nil {
return fmt.Errorf("API call failed while waiting for resource deletion")
}
@@ -58,35 +55,6 @@ func checkConnectionDelete(s *terraform.State) error {
return nil
}
-func waitUntilConnectionDeprovisioned(uuid string, client *v4.APIClient, ctx context.Context) (v4.Connection, error) {
- log.Printf("Waiting for connection to be in deprovisioned, uuid %s", uuid)
- stateConf := &resource.StateChangeConf{
- Target: []string{"DEPROVISIONED"},
- Refresh: func() (interface{}, string, error) {
- dbConn, _, err := client.ConnectionsApi.GetConnectionByUuid(ctx, uuid, nil)
- if err != nil {
- return "", "", err
- }
- updatableState := ""
- if "DEPROVISIONED" == *dbConn.State {
- updatableState = string(*dbConn.State)
- }
- return dbConn, updatableState, nil
- },
- Timeout: 3 * time.Minute,
- Delay: 30 * time.Second,
- MinTimeout: 30 * time.Second,
- }
-
- inter, err := stateConf.WaitForStateContext(ctx)
- dbConn := v4.Connection{}
-
- if err == nil {
- dbConn = inter.(v4.Connection)
- }
- return dbConn, err
-}
-
func testAccFabricCreateEPLConnectionConfig(bandwidth int32) string {
return fmt.Sprintf(`resource "equinix_fabric_connection" "test" {
type = "EVPL_VC"
diff --git a/equinix/resource_fabric_port.go b/equinix/resource_fabric_port.go
index c586ebd38..706781cf2 100755
--- a/equinix/resource_fabric_port.go
+++ b/equinix/resource_fabric_port.go
@@ -3,19 +3,19 @@ package equinix
import (
"context"
"fmt"
+ "log"
+ "strings"
+
"github.com/antihax/optional"
v4 "github.com/equinix-labs/fabric-go/fabric/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
- "log"
- "strings"
)
func resourceFabricPortRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*Config).fabricClient
ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*Config).FabricAuthToken)
port, _, err := client.PortsApi.GetPortByUuid(ctx, d.Id())
-
if err != nil {
log.Printf("[WARN] Port %s not found , error %s", d.Id(), err)
if !strings.Contains(err.Error(), "500") {
@@ -68,7 +68,7 @@ func setPortsListMap(d *schema.ResourceData, spl v4.AllPortsResponse) diag.Diagn
func resourceFabricPortGetByPortName(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
client := meta.(*Config).fabricClient
ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*Config).FabricAuthToken)
- portNameParam := d.Get("filters").(interface{}).(*schema.Set).List()
+ portNameParam := d.Get("filters").(*schema.Set).List()
portName := portNameQueryParamToFabric(portNameParam)
ports, _, err := client.PortsApi.GetPorts(ctx, &portName)
if err != nil {
@@ -89,13 +89,13 @@ func resourceFabricPortGetByPortName(ctx context.Context, d *schema.ResourceData
}
func portNameQueryParamToFabric(portNameParam []interface{}) v4.PortsApiGetPortsOpts {
- if portNameParam == nil || len(portNameParam) == 0 {
+ if len(portNameParam) == 0 {
return v4.PortsApiGetPortsOpts{}
}
mappedPn := v4.PortsApiGetPortsOpts{}
for _, pn := range portNameParam {
pnMap := pn.(map[string]interface{})
- portName := pnMap["name"].(interface{}).(string)
+ portName := pnMap["name"].(string)
pName := optional.NewString(portName)
mappedPn = v4.PortsApiGetPortsOpts{Name: pName}
}
diff --git a/equinix/resource_fabric_port_acc_test.go b/equinix/resource_fabric_port_acc_test.go
index 62d75b2aa..3b46b3f6c 100755
--- a/equinix/resource_fabric_port_acc_test.go
+++ b/equinix/resource_fabric_port_acc_test.go
@@ -2,8 +2,9 @@ package equinix
import (
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"testing"
+
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
func TestAccFabricReadPort(t *testing.T) {
@@ -28,7 +29,7 @@ func testAccFabricReadPortConfig() string {
}`)
}
-//Get Ports By Name
+// Get Ports By Name
func testAccFabricReadGetPortsByNameConfig(name string) string {
return fmt.Sprintf(`data "equinix_fabric_ports" "test" {
filters {
diff --git a/equinix/resource_fabric_service_profile.go b/equinix/resource_fabric_service_profile.go
index becf7ad31..0663896a2 100755
--- a/equinix/resource_fabric_service_profile.go
+++ b/equinix/resource_fabric_service_profile.go
@@ -3,14 +3,15 @@ package equinix
import (
"context"
"fmt"
- v4 "github.com/equinix-labs/fabric-go/fabric/v4"
- "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
"strconv"
"strings"
"time"
+
+ v4 "github.com/equinix-labs/fabric-go/fabric/v4"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)
func resourceFabricServiceProfile() *schema.Resource {
@@ -37,7 +38,6 @@ func resourceFabricServiceProfileRead(ctx context.Context, d *schema.ResourceDat
client := meta.(*Config).fabricClient
ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*Config).FabricAuthToken)
serviceProfile, _, err := client.ServiceProfilesApi.GetServiceProfileByUuid(ctx, d.Id(), nil)
-
if err != nil {
if !strings.Contains(err.Error(), "500") {
error := v4.ModelError{}
@@ -89,7 +89,7 @@ func getServiceProfileRequestPayload(d *schema.ResourceData) v4.ServiceProfileRe
schemaCustomFields := d.Get("custom_fields").([]interface{})
spCustomFields := customFieldsToFabric(schemaCustomFields)
- schemaMarketingInfo := d.Get("marketing_info").(interface{}).(*schema.Set).List()
+ schemaMarketingInfo := d.Get("marketing_info").(*schema.Set).List()
spMarketingInfo := marketingInfoToFabric(schemaMarketingInfo)
schemaPorts := d.Get("ports").([]interface{})
@@ -124,11 +124,6 @@ func resourceFabricServiceProfileUpdate(ctx context.Context, d *schema.ResourceD
client := meta.(*Config).fabricClient
ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*Config).FabricAuthToken)
uuid := d.Id()
- //TODO Why we need the below check?
- if uuid == "" {
- return diag.Errorf("No service profile found for the value uuid %v ", uuid)
- }
-
updateRequest := getServiceProfileRequestPayload(d)
var err error
@@ -143,7 +138,7 @@ func resourceFabricServiceProfileUpdate(ctx context.Context, d *schema.ResourceD
_, res, err := client.ServiceProfilesApi.PutServiceProfileByUuid(ctx, updateRequest, strconv.FormatInt(eTag, 10), uuid)
if err != nil {
- return diag.FromErr(fmt.Errorf("Error response for the service profile update, response %v, error %v", res, err))
+ return diag.FromErr(fmt.Errorf("error response for the service profile update, response %v, error %v", res, err))
}
updatedServiceProfile := v4.ServiceProfile{}
updatedServiceProfile, err = waitForServiceProfileUpdateCompletion(uuid, meta, ctx)
@@ -151,7 +146,7 @@ func resourceFabricServiceProfileUpdate(ctx context.Context, d *schema.ResourceD
if !strings.Contains(err.Error(), "500") {
d.SetId("")
}
- return diag.FromErr(fmt.Errorf("Errored while waiting for successful service profile update, response %v, error %v", res, err))
+ return diag.FromErr(fmt.Errorf("errored while waiting for successful service profile update, response %v, error %v", res, err))
}
d.SetId(updatedServiceProfile.Uuid)
return setFabricServiceProfileMap(d, updatedServiceProfile)
@@ -188,7 +183,7 @@ func waitForActiveServiceProfileAndPopulateETag(uuid string, meta interface{}, c
log.Printf("Waiting for service profile to be in active state, uuid %s", uuid)
var eTag int64 = 0
stateConf := &resource.StateChangeConf{
- Target: []string{"ACTIVE"},
+ Target: []string{string(v4.ACTIVE_ServiceProfileStateEnum)},
Refresh: func() (interface{}, string, error) {
client := meta.(*Config).fabricClient
dbServiceProfile, res, err := client.ServiceProfilesApi.GetServiceProfileByUuid(ctx, uuid, nil)
@@ -198,9 +193,12 @@ func waitForActiveServiceProfileAndPopulateETag(uuid string, meta interface{}, c
eTagStr := res.Header.Get("ETag")
eTag, err = strconv.ParseInt(strings.Trim(eTagStr, "\""), 10, 64)
+ if err != nil {
+ return nil, "", err
+ }
updatableState := ""
- if "ACTIVE" == *dbServiceProfile.State {
+ if *dbServiceProfile.State == v4.ACTIVE_ServiceProfileStateEnum {
updatableState = string(*dbServiceProfile.State)
}
return dbServiceProfile, updatableState, nil
@@ -227,8 +225,7 @@ func resourceFabricServiceProfileDelete(ctx context.Context, d *schema.ResourceD
}
_, resp, err := client.ServiceProfilesApi.DeleteServiceProfileByUuid(ctx, uuid)
if err != nil {
- fmt.Errorf("Error response for the Service Profile delete error %v and response %v", err, resp)
- return diag.FromErr(err)
+ return diag.FromErr(fmt.Errorf("error response for the Service Profile delete error %v and response %v", err, resp))
}
return diags
}
@@ -268,20 +265,17 @@ func setFabricServiceProfilesListMap(d *schema.ResourceData, spl v4.ServiceProfi
"data": fabricServiceProfilesListToTerra(spl),
})
if err != nil {
-
return diag.FromErr(err)
-
}
return diags
}
func resourceServiceProfilesSearchRequest(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
-
client := meta.(*Config).fabricClient
ctx = context.WithValue(ctx, v4.ContextAccessToken, meta.(*Config).FabricAuthToken)
- schemaFilter := d.Get("filter").(interface{}).(*schema.Set).List()
+ schemaFilter := d.Get("filter").(*schema.Set).List()
filter := serviceProfilesSearchFilterRequestToFabric(schemaFilter)
- var serviceProfileFlt v4.ServiceProfileFilter //Cast ServiceProfile search expression struct type to interface
+ var serviceProfileFlt v4.ServiceProfileFilter // Cast ServiceProfile search expression struct type to interface
serviceProfileFlt = filter
schemaSort := d.Get("sort").([]interface{})
sort := serviceProfilesSearchSortRequestToFabric(schemaSort)
@@ -290,7 +284,6 @@ func resourceServiceProfilesSearchRequest(ctx context.Context, d *schema.Resourc
Sort: sort,
}
serviceProfiles, _, err := client.ServiceProfilesApi.SearchServiceProfiles(ctx, createServiceProfilesSearchRequest)
-
if err != nil {
if !strings.Contains(err.Error(), "500") {
error := v4.ModelError{}
diff --git a/equinix/resource_fabric_service_profile_acc_test.go b/equinix/resource_fabric_service_profile_acc_test.go
index 0009a72c0..e7c7d5548 100755
--- a/equinix/resource_fabric_service_profile_acc_test.go
+++ b/equinix/resource_fabric_service_profile_acc_test.go
@@ -3,12 +3,13 @@ package equinix
import (
"context"
"fmt"
- "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
- "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
"log"
"testing"
"time"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
+ "github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
+
v4 "github.com/equinix-labs/fabric-go/fabric/v4"
)
@@ -57,7 +58,7 @@ func TestAccFabricSearchServiceProfilesByName(t *testing.T) {
Config: testAccFabricReadServiceProfilesListConfig("Azure ExpressRoute"),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(
- "data.equinix_fabric_service_profiles.test", "data.#", fmt.Sprint(1)), //Check total number of ServiceProfile list returned in the Response payloads
+ "data.equinix_fabric_service_profiles.test", "data.#", fmt.Sprint(1)), // Check total number of ServiceProfile list returned in the Response payloads
resource.TestCheckResourceAttr(
"data.equinix_fabric_service_profiles.test", "data.0.name", fmt.Sprint("Azure ExpressRoute")),
resource.TestCheckResourceAttr(
@@ -166,14 +167,14 @@ func checkServiceProfileDelete(s *terraform.State) error {
func waitAndCheckServiceProfileDeleted(uuid string, client *v4.APIClient, ctx context.Context) (v4.ServiceProfile, error) {
log.Printf("Waiting for service profile to be in deleted, uuid %s", uuid)
stateConf := &resource.StateChangeConf{
- Target: []string{"DELETED"},
+ Target: []string{string(v4.DELETED_ServiceProfileStateEnum)},
Refresh: func() (interface{}, string, error) {
dbConn, _, err := client.ServiceProfilesApi.GetServiceProfileByUuid(ctx, uuid, nil)
if err != nil {
return "", "", err
}
updatableState := ""
- if "DELETED" == *dbConn.State {
+ if *dbConn.State == v4.DELETED_ServiceProfileStateEnum {
updatableState = string(*dbConn.State)
}
return dbConn, updatableState, nil
diff --git a/examples/connectivity/v4/alibaba/main.tf b/examples/connectivity/v4/alibaba/main.tf
index 74a2b0173..5e5454df5 100644
--- a/examples/connectivity/v4/alibaba/main.tf
+++ b/examples/connectivity/v4/alibaba/main.tf
@@ -62,9 +62,3 @@ resource "equinix_fabric_connection" "alibaba-qinq" {
output "connection_result" {
value = equinix_fabric_connection.alibaba-qinq.id
}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "180s"
-
- depends_on = [equinix_fabric_connection.alibaba-qinq]
-}
\ No newline at end of file
diff --git a/examples/connectivity/v4/aws/main.tf b/examples/connectivity/v4/aws/main.tf
index ffb25a705..799fbaafa 100644
--- a/examples/connectivity/v4/aws/main.tf
+++ b/examples/connectivity/v4/aws/main.tf
@@ -60,10 +60,5 @@ resource "equinix_fabric_connection" "aws-qinq" {
}
output "connection_result" {
- value = "equinix_fabric_connection.aws-qinq.id"
+ value = equinix_fabric_connection.aws-qinq.id
}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "60s"
- depends_on = [equinix_fabric_connection.aws-qinq]
-}
\ No newline at end of file
diff --git a/examples/connectivity/v4/azure/main.tf b/examples/connectivity/v4/azure/main.tf
index 77f6f559b..2813559d6 100644
--- a/examples/connectivity/v4/azure/main.tf
+++ b/examples/connectivity/v4/azure/main.tf
@@ -59,10 +59,5 @@ resource "equinix_fabric_connection" "azure-qinq" {
}
output "connection_result" {
- value = "equinix_fabric_connection.azure-qinq.id"
+ value = equinix_fabric_connection.azure-qinq.id
}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "300s"
- depends_on = [equinix_fabric_connection.azure-qinq]
-}
\ No newline at end of file
diff --git a/examples/connectivity/v4/google/main.tf b/examples/connectivity/v4/google/main.tf
index 14e8c5e98..54fb327e3 100644
--- a/examples/connectivity/v4/google/main.tf
+++ b/examples/connectivity/v4/google/main.tf
@@ -60,11 +60,5 @@ resource "equinix_fabric_connection" "gcp-qinq" {
}
output "connection_result" {
- value = "equinix_fabric_connection.gcp-qinq.id"
+ value = equinix_fabric_connection.gcp-qinq.id
}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "300s"
-
- depends_on = [equinix_fabric_connection.gcp-qinq]
-}
\ No newline at end of file
diff --git a/examples/connectivity/v4/oracle/main.tf b/examples/connectivity/v4/oracle/main.tf
index eb8605f10..78756776a 100644
--- a/examples/connectivity/v4/oracle/main.tf
+++ b/examples/connectivity/v4/oracle/main.tf
@@ -59,10 +59,5 @@ resource "equinix_fabric_connection" "oracle-qinq" {
}
output "connection_result" {
- value = "equinix_fabric_connection.oracle-qinq.id"
-}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "120s"
- depends_on = [equinix_fabric_connection.oracle-qinq]
+ value = equinix_fabric_connection.oracle-qinq.id
}
diff --git a/examples/connectivity/v4/port2portself/main.tf b/examples/connectivity/v4/port2portself/main.tf
index 204838ab8..09d516d4d 100644
--- a/examples/connectivity/v4/port2portself/main.tf
+++ b/examples/connectivity/v4/port2portself/main.tf
@@ -56,11 +56,5 @@ resource "equinix_fabric_connection" "p2p-qinq" {
}
output "connection_result" {
- value = "equinix_fabric_connection.p2p-qinq.id"
+ value = equinix_fabric_connection.p2p-qinq.id
}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "180s"
-
- depends_on = [equinix_fabric_connection.p2p-qinq]
-}
\ No newline at end of file
diff --git a/examples/connectivity/v4/port2serviceprofileprivate/main.tf b/examples/connectivity/v4/port2serviceprofileprivate/main.tf
index 1f9bb7723..8b56e58f2 100644
--- a/examples/connectivity/v4/port2serviceprofileprivate/main.tf
+++ b/examples/connectivity/v4/port2serviceprofileprivate/main.tf
@@ -68,10 +68,5 @@ resource "equinix_fabric_connection" "sp-private-qinq" {
}
output "connection_result" {
- value = "equinix_fabric_connection.sp-private-qinq.id"
+ value = equinix_fabric_connection.sp-private-qinq.id
}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "60s"
- depends_on = [equinix_fabric_connection.sp-private-qinq]
-}
\ No newline at end of file
diff --git a/examples/connectivity/v4/port2serviceprofilepublic/main.tf b/examples/connectivity/v4/port2serviceprofilepublic/main.tf
index 2ca206ad7..c2e5f51a0 100644
--- a/examples/connectivity/v4/port2serviceprofilepublic/main.tf
+++ b/examples/connectivity/v4/port2serviceprofilepublic/main.tf
@@ -59,9 +59,3 @@ resource "equinix_fabric_connection" "port2profile" {
output "connection_result" {
value = equinix_fabric_connection.port2profile.id
}
-
-resource "time_sleep" "wait_for_ingress_alb" {
- destroy_duration = "180s"
-
- depends_on = [equinix_fabric_connection.port2profile]
-}
\ No newline at end of file
diff --git a/tests/connection_e2e_port2port_test.go b/tests/connection_e2e_port2port_test.go
index 311240f0d..850ac91b2 100644
--- a/tests/connection_e2e_port2port_test.go
+++ b/tests/connection_e2e_port2port_test.go
@@ -1,9 +1,10 @@
package tests
import (
+ "testing"
+
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
- "testing"
)
func TestPort2PortCreateConnection(t *testing.T) {
@@ -17,5 +18,4 @@ func TestPort2PortCreateConnection(t *testing.T) {
terraform.InitAndApply(t, terraformOptions)
output := terraform.Output(t, terraformOptions, "connection_result")
assert.NotNil(t, output)
-
}
diff --git a/tests/connection_e2e_port2profile_public_test.go b/tests/connection_e2e_port2profile_public_test.go
index 88946fc37..3e261f0df 100644
--- a/tests/connection_e2e_port2profile_public_test.go
+++ b/tests/connection_e2e_port2profile_public_test.go
@@ -1,9 +1,10 @@
package tests
import (
+ "testing"
+
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
- "testing"
)
func TestPort2ProfilePublicCreateConnection(t *testing.T) {
@@ -18,5 +19,4 @@ func TestPort2ProfilePublicCreateConnection(t *testing.T) {
output := terraform.Output(t, terraformOptions, "connection_result")
terraform.OutputAll(t, terraformOptions)
assert.NotNil(t, output)
-
}
diff --git a/tests/serviceprofile_e2e_generic_test.go b/tests/serviceprofile_e2e_generic_test.go
index c52ee2ef8..58af9aac7 100644
--- a/tests/serviceprofile_e2e_generic_test.go
+++ b/tests/serviceprofile_e2e_generic_test.go
@@ -1,10 +1,11 @@
package tests
import (
+ "testing"
+
"github.com/gruntwork-io/terratest/modules/logger"
"github.com/gruntwork-io/terratest/modules/terraform"
"github.com/stretchr/testify/assert"
- "testing"
)
func TestCreateServiceProfileGeneric(t *testing.T) {
@@ -21,5 +22,4 @@ func TestCreateServiceProfileGeneric(t *testing.T) {
output := terraform.OutputAll(t, terraformOptions)
assert.NotNil(t, output)
assert.NotEmpty(t, output)
-
}