diff --git a/docs/data-sources/equinix_fabric_cloud_router.md b/docs/data-sources/equinix_fabric_cloud_router.md index 61402c613..bc9fdff89 100644 --- a/docs/data-sources/equinix_fabric_cloud_router.md +++ b/docs/data-sources/equinix_fabric_cloud_router.md @@ -87,9 +87,9 @@ output "type" { - `notifications` (List of Object) Preferences for notifications on Fabric Cloud Router configuration or status changes (see [below for nested schema](#nestedatt--notifications)) - `order` (Set of Object) Order information related to this Fabric Cloud Router (see [below for nested schema](#nestedatt--order)) - `package` (Set of Object) Fabric Cloud Router Package Type (see [below for nested schema](#nestedatt--package)) -- `project` (Set of Object) Customer resource hierarchy project information.Applicable to customers onboarded to Equinix Identity and Access Management. For more information see Identity and Access Management: Projects (see [below for nested schema](#nestedatt--project)) +- `project` (Set of Object) Customer resource hierarchy project information. Applicable to customers onboarded to Equinix Identity and Access Management. For more information see Identity and Access Management: Projects (see [below for nested schema](#nestedatt--project)) - `state` (String) Fabric Cloud Router overall state -- `type` (String) Defines the FCR type like; XF_ROUTER +- `type` (String) Defines the FCR type. One of [XF_ROUTER] ### Nested Schema for `account` @@ -123,7 +123,6 @@ Read-Only: Read-Only: -- `ibx` (String) - `metro_code` (String) - `metro_name` (String) - `region` (String) @@ -163,6 +162,6 @@ Read-Only: Read-Only: -- `href` (String) - `project_id` (String) + diff --git a/docs/data-sources/equinix_fabric_cloud_routers.md b/docs/data-sources/equinix_fabric_cloud_routers.md index de63ddecc..11f72b586 100644 --- a/docs/data-sources/equinix_fabric_cloud_routers.md +++ b/docs/data-sources/equinix_fabric_cloud_routers.md @@ -205,7 +205,6 @@ Read-Only: Read-Only: -- `ibx` (String) - `metro_code` (String) - `metro_name` (String) - `region` (String) @@ -245,5 +244,6 @@ Read-Only: Read-Only: -- `href` (String) - `project_id` (String) + + diff --git a/docs/data-sources/equinix_fabric_connection.md b/docs/data-sources/equinix_fabric_connection.md index 9112dc2fc..7837689f0 100644 --- a/docs/data-sources/equinix_fabric_connection.md +++ b/docs/data-sources/equinix_fabric_connection.md @@ -115,7 +115,7 @@ output "access_point_provider_connection_id" { - `project` (Set of Object) Project information (see [below for nested schema](#nestedatt--project)) - `redundancy` (Set of Object) Connection Redundancy Configuration (see [below for nested schema](#nestedatt--redundancy)) - `state` (String) Connection overall state -- `type` (String) Defines the connection type like EVPL_VC, EPL_VC, IPWAN_VC, IP_VC, ACCESS_EPL_VC, EVPLAN_VC, EPLAN_VC, EIA_VC, EC_VC +- `type` (String) Defines the connection type. One of [EVPL_VC EPL_VC EC_VC IP_VC ACCESS_EPL_VC EIA_VC EVPLAN_VC EPLAN_VC IPWAN_VC IA_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)) @@ -134,7 +134,7 @@ Read-Only: - `account` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--account)) - `authentication_key` (String) -- `gateway` (Set of Object, Deprecated) **Deprecated** `gateway` Use `router` attribute instead (see [below for nested schema](#nestedobjatt--a_side--access_point--gateway)) +- `gateway` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--gateway)) - `interface` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--interface)) - `link_protocol` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--link_protocol)) - `location` (Set of Object) (see [below for nested schema](#nestedobjatt--a_side--access_point--location)) @@ -390,7 +390,6 @@ Read-Only: Read-Only: -- `href` (String) - `project_id` (String) @@ -419,7 +418,7 @@ Read-Only: - `account` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--account)) - `authentication_key` (String) -- `gateway` (Set of Object, Deprecated) **Deprecated** `gateway` Use `router` attribute instead (see [below for nested schema](#nestedobjatt--z_side--access_point--gateway)) +- `gateway` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--gateway)) - `interface` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--interface)) - `link_protocol` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--link_protocol)) - `location` (Set of Object) (see [below for nested schema](#nestedobjatt--z_side--access_point--location)) @@ -580,3 +579,5 @@ Read-Only: - `href` (String) - `type` (String) - `uuid` (String) + + diff --git a/docs/data-sources/equinix_fabric_network.md b/docs/data-sources/equinix_fabric_network.md index d3f9c11d8..261272be9 100644 --- a/docs/data-sources/equinix_fabric_network.md +++ b/docs/data-sources/equinix_fabric_network.md @@ -61,9 +61,9 @@ output "region" { - `notifications` (List of Object) Preferences for notifications on Fabric Network configuration or status changes (see [below for nested schema](#nestedatt--notifications)) - `operation` (Set of Object) Network operation information that is associated with this Fabric Network (see [below for nested schema](#nestedatt--operation)) - `project` (Set of Object) Fabric Network project (see [below for nested schema](#nestedatt--project)) -- `scope` (String) Fabric Network scope +- `scope` (String) Fabric Network scope. One of [REGIONAL GLOBAL LOCAL] - `state` (String) Fabric Network overall state -- `type` (String) Supported Network types - EVPLAN, EPLAN, IPWAN +- `type` (String) Supported Network types. One of [REGIONAL GLOBAL LOCAL] ### Nested Schema for `change` @@ -130,3 +130,4 @@ Read-Only: - `project_id` (String) + diff --git a/docs/data-sources/equinix_fabric_port.md b/docs/data-sources/equinix_fabric_port.md index 556e93ee3..b63b44f29 100644 --- a/docs/data-sources/equinix_fabric_port.md +++ b/docs/data-sources/equinix_fabric_port.md @@ -118,6 +118,7 @@ Read-Only: - `global_organization_name` (String) - `org_id` (Number) - `organization_name` (String) +- `ucm_id` (String) @@ -196,3 +197,5 @@ Read-Only: - `enabled` (Boolean) - `group` (String) - `priority` (String) + + diff --git a/docs/data-sources/equinix_fabric_ports.md b/docs/data-sources/equinix_fabric_ports.md index 9006326a7..d709f3cd4 100644 --- a/docs/data-sources/equinix_fabric_ports.md +++ b/docs/data-sources/equinix_fabric_ports.md @@ -137,6 +137,7 @@ Read-Only: - `global_organization_name` (String) - `org_id` (Number) - `organization_name` (String) +- `ucm_id` (String) @@ -215,3 +216,5 @@ Read-Only: - `enabled` (Boolean) - `group` (String) - `priority` (String) + + diff --git a/docs/data-sources/equinix_fabric_routing_protocol.md b/docs/data-sources/equinix_fabric_routing_protocol.md index 51c1afeb6..d31f481bb 100644 --- a/docs/data-sources/equinix_fabric_routing_protocol.md +++ b/docs/data-sources/equinix_fabric_routing_protocol.md @@ -201,3 +201,5 @@ Read-Only: - `property` (String) - `reason` (String) + + diff --git a/docs/data-sources/equinix_fabric_service_profile.md b/docs/data-sources/equinix_fabric_service_profile.md index 87a6578a9..b70045765 100644 --- a/docs/data-sources/equinix_fabric_service_profile.md +++ b/docs/data-sources/equinix_fabric_service_profile.md @@ -92,7 +92,8 @@ output "allow_over_subscription" { - `self_profile` (Boolean) Self Profile indicating if the profile is created for customer's self use - `state` (String) Service profile state - ACTIVE, PENDING_APPROVAL, DELETED, REJECTED - `tags` (List of String) Tags attached to the connection -- `type` (String) Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE +- `type` (String) Service profile type. One of [L2_PROFILE L3_PROFILE IA_PROFILE] +- `view_point` (String) Flips view between buyer and seller representation. Available values : aSide, zSide. Default value : aSide - `virtual_devices` (List of Object) Virtual Devices (see [below for nested schema](#nestedatt--virtual_devices)) - `visibility` (String) Service profile visibility - PUBLIC, PRIVATE @@ -270,7 +271,6 @@ Read-Only: Read-Only: -- `href` (String) - `project_id` (String) @@ -293,3 +293,5 @@ Read-Only: - `metro_code` (String) - `metro_name` (String) - `region` (String) + + diff --git a/docs/data-sources/equinix_fabric_service_profiles.md b/docs/data-sources/equinix_fabric_service_profiles.md index 347ddd63f..b7e1727a2 100644 --- a/docs/data-sources/equinix_fabric_service_profiles.md +++ b/docs/data-sources/equinix_fabric_service_profiles.md @@ -126,6 +126,7 @@ Read-Only: - `tags` (List of String) - `type` (String) - `uuid` (String) +- `view_point` (String) - `virtual_devices` (List of Object) (see [below for nested schema](#nestedobjatt--data--virtual_devices)) - `visibility` (String) @@ -303,7 +304,6 @@ Read-Only: Read-Only: -- `href` (String) - `project_id` (String) @@ -326,3 +326,5 @@ Read-Only: - `metro_code` (String) - `metro_name` (String) - `region` (String) + + diff --git a/docs/resources/equinix_fabric_cloud_router.md b/docs/resources/equinix_fabric_cloud_router.md index 717de29c5..6b5b518a7 100644 --- a/docs/resources/equinix_fabric_cloud_router.md +++ b/docs/resources/equinix_fabric_cloud_router.md @@ -53,13 +53,13 @@ resource "equinix_fabric_cloud_router" "new_cloud_router"{ - `notifications` (Block List, Min: 1) Preferences for notifications on Fabric Cloud Router configuration or status changes (see [below for nested schema](#nestedblock--notifications)) - `package` (Block Set, Min: 1, Max: 1) Fabric Cloud Router Package Type (see [below for nested schema](#nestedblock--package)) - `project` (Block Set, Min: 1, Max: 1) Customer resource hierarchy project information. Applicable to customers onboarded to Equinix Identity and Access Management. For more information see Identity and Access Management: Projects (see [below for nested schema](#nestedblock--project)) -- `type` (String) Defines the FCR type like; XF_ROUTER +- `type` (String) Defines the FCR type. One of [XF_ROUTER] ### Optional - `description` (String) Customer-provided Fabric Cloud Router description - `href` (String) Fabric Cloud Router URI information -- `order` (Block Set, Min: 1, Max: 1) Order information related to this Fabric Cloud Router (see [below for nested schema](#nestedblock--order)) +- `order` (Block Set, Max: 1) Order information related to this Fabric Cloud Router (see [below for nested schema](#nestedblock--order)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `uuid` (String) Equinix-assigned Fabric Cloud Router identifier @@ -78,7 +78,7 @@ resource "equinix_fabric_cloud_router" "new_cloud_router"{ ### Nested Schema for `account` -Optional: +Required: - `account_number` (Number) Account Number @@ -86,10 +86,12 @@ Optional: ### Nested Schema for `location` -Optional: +Required: -- `ibx` (String) IBX Code - `metro_code` (String) Access point metro code + +Read-Only: + - `metro_name` (String) Access point metro name - `region` (String) Access point region @@ -100,44 +102,43 @@ Optional: Required: - `emails` (List of String) Array of contact emails -- `type` (String) Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS +- `type` (String) Notification type. One of [NOTIFICATION BANDWIDTH_ALERT CONNECTION_APPROVAL PROFILE_LIFECYCLE ALL SALES_REP_NOTIFICATIONS] Optional: - `send_interval` (String) Send interval - -### Nested Schema for `order` - -Optional: - -- `purchase_order_number` (String) Purchase order number - -Read-Only: - -- `billing_tier` (String) Billing tier for connection bandwidth -- `order_id` (String) Order Identification -- `order_number` (String) Order Reference Number - - ### Nested Schema for `package` Required: -- `code` (String) Fabric Cloud Router package code +- `code` (String) Fabric Cloud Router package code. One of [LAB ADVANCED STANDARD PREMIUM] ### Nested Schema for `project` -Optional: +Required: -- `href` (String) Unique Resource URL - `project_id` (String) Project Id + +### Nested Schema for `order` + +Optional: + +- `purchase_order_number` (String) Purchase order number. Short name/number to identify this order on the invoice + +Read-Only: + +- `billing_tier` (String) Billing tier for connection bandwidth +- `order_id` (String) Order Identification +- `order_number` (String) Order Reference Number + + ### Nested Schema for `timeouts` diff --git a/docs/resources/equinix_fabric_connection.md b/docs/resources/equinix_fabric_connection.md index 895037027..cde6dfe03 100644 --- a/docs/resources/equinix_fabric_connection.md +++ b/docs/resources/equinix_fabric_connection.md @@ -667,14 +667,14 @@ Port to IBM Connections could be modified from IBM Service Provider Side by usin - `bandwidth` (Number) Connection bandwidth in Mbps - `name` (String) Connection name. An alpha-numeric 24 characters string which can include only hyphens and underscores - `notifications` (Block List, Min: 1) Preferences for notifications on connection configuration or status changes (see [below for nested schema](#nestedblock--notifications)) -- `type` (String) Defines the connection type like EVPL_VC, EPL_VC, IPWAN_VC, IP_VC, ACCESS_EPL_VC, EVPLAN_VC, EPLAN_VC, EIA_VC, EC_VC +- `type` (String) Defines the connection type. One of [EVPL_VC EPL_VC EC_VC IP_VC ACCESS_EPL_VC EIA_VC EVPLAN_VC EPLAN_VC IPWAN_VC IA_VC] - `z_side` (Block Set, Min: 1, Max: 1) Destination or Provider side connection configuration object of the multi-segment connection (see [below for nested schema](#nestedblock--z_side)) ### Optional - `additional_info` (List of Map of String) Connection additional information - `description` (String) Customer-provided connection description -- `order` (Block Set, Min: 1, Max: 1) Order details (see [below for nested schema](#nestedblock--order)) +- `order` (Block Set, Max: 1) Order details (see [below for nested schema](#nestedblock--order)) - `project` (Block Set, Max: 1) Project information (see [below for nested schema](#nestedblock--project)) - `redundancy` (Block Set, Max: 1) Connection Redundancy Configuration (see [below for nested schema](#nestedblock--redundancy)) - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) @@ -711,18 +711,18 @@ Optional: - `link_protocol` (Block Set, Max: 1) Connection link protocol (see [below for nested schema](#nestedblock--a_side--access_point--link_protocol)) - `location` (Block Set, Max: 1) Access point location (see [below for nested schema](#nestedblock--a_side--access_point--location)) - `network` (Block Set, Max: 1) network access point information (see [below for nested schema](#nestedblock--a_side--access_point--network)) -- `peering_type` (String) Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL +- `peering_type` (String) Peering type. One of [PRIVATE MICROSOFT PUBLIC MANUAL] - `port` (Block Set, Max: 1) Port access point information (see [below for nested schema](#nestedblock--a_side--access_point--port)) - `profile` (Block Set, Max: 1) Service Profile (see [below for nested schema](#nestedblock--a_side--access_point--profile)) -- `provider_connection_id` (String) Provider assigned Connection Id - `router` (Block Set, Max: 1) Cloud Router access point information that replaces `gateway` (see [below for nested schema](#nestedblock--a_side--access_point--router)) - `seller_region` (String) Access point seller region -- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK +- `type` (String) Access point type. One of [VD VG SP IGW COLO SUBNET CLOUD_ROUTER NETWORK METAL_NETWORK] - `virtual_device` (Block Set, Max: 1) Virtual device (see [below for nested schema](#nestedblock--a_side--access_point--virtual_device)) Read-Only: -- `account` (Block Set) Account (see [below for nested schema](#nestedblock--a_side--access_point--account)) +- `account` (Set of Object) Account (see [below for nested schema](#nestedatt--a_side--access_point--account)) +- `provider_connection_id` (String) Provider assigned Connection Id ### Nested Schema for `a_side.access_point.gateway` @@ -739,19 +739,28 @@ Read-Only: ### Nested Schema for `a_side.access_point.interface` +Required: + +- `type` (String) Interface type. One of [CLOUD NETWORK] + Optional: - `id` (Number) id -- `type` (String) Interface type + +Read-Only: + - `uuid` (String) Equinix-assigned interface identifier ### Nested Schema for `a_side.access_point.link_protocol` +Required: + +- `type` (String) Type of the link protocol. One of [UNTAGGED DOT1Q QINQ EVPN_VXLAN VXLAN] + Optional: -- `type` (String) Type of the link protocol - UNTAGGED, DOT1Q, QINQ, EVPN_VXLAN - `vlan_c_tag` (Number) Vlan Customer Tag information, vlanCTag value specified for QINQ connections - `vlan_s_tag` (Number) Vlan Provider Tag information, vlanSTag value specified for QINQ connections - `vlan_tag` (Number) Vlan Tag information, vlanTag value specified for DOT1Q connections @@ -760,10 +769,13 @@ Optional: ### Nested Schema for `a_side.access_point.location` -Optional: +Required: -- `ibx` (String) IBX Code - `metro_code` (String) Access point metro code + +Read-Only: + +- `ibx` (String) IBX Code - `metro_name` (String) Access point metro name - `region` (String) Access point region @@ -771,7 +783,7 @@ Optional: ### Nested Schema for `a_side.access_point.network` -Optional: +Required: - `uuid` (String) Equinix-assigned Network identifier @@ -783,7 +795,7 @@ Read-Only: ### Nested Schema for `a_side.access_point.port` -Optional: +Required: - `uuid` (String) Equinix-assigned Port identifier @@ -809,7 +821,7 @@ Read-Only: Required: -- `type` (String) Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE +- `type` (String) Service profile type. One of [L2_PROFILE L3_PROFILE IA_PROFILE] - `uuid` (String) Equinix assigned service profile identifier Read-Only: @@ -844,37 +856,37 @@ Read-Only: ### Nested Schema for `a_side.access_point.virtual_device` -Optional: +Required: -- `name` (String) Customer-assigned Virtual Device Name -- `type` (String) Virtual Device type +- `type` (String) Virtual Device type. One of [EDGE] - `uuid` (String) Equinix-assigned Virtual Device identifier Read-Only: - `href` (String) Unique Resource Identifier +- `name` (String) Customer-assigned Virtual Device Name - + ### Nested Schema for `a_side.access_point.account` Read-Only: -- `account_name` (String) Legal name of the accountholder. -- `account_number` (Number) Equinix-assigned account number. -- `global_cust_id` (String) Equinix-assigned ID of the subscriber's parent organization. -- `global_org_id` (String) Equinix-assigned ID of the subscriber's parent organization. -- `global_organization_name` (String) Equinix-assigned name of the subscriber's parent organization. -- `org_id` (Number) Equinix-assigned ID of the subscriber's organization. -- `organization_name` (String) Equinix-assigned name of the subscriber's organization. -- `ucm_id` (String) Enterprise datastore id +- `account_name` (String) +- `account_number` (Number) +- `global_cust_id` (String) +- `global_org_id` (String) +- `global_organization_name` (String) +- `org_id` (Number) +- `organization_name` (String) +- `ucm_id` (String) ### Nested Schema for `a_side.additional_info` -Optional: +Required: - `key` (String) Additional information key - `value` (String) Additional information value @@ -885,7 +897,7 @@ Optional: Optional: -- `type` (String) Token type - VC_TOKEN +- `type` (String) Token type. One of [VC_TOKEN] - `uuid` (String) Equinix-assigned service token identifier Read-Only: @@ -901,27 +913,13 @@ Read-Only: Required: - `emails` (List of String) Array of contact emails -- `type` (String) Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS +- `type` (String) Notification type. One of [NOTIFICATION BANDWIDTH_ALERT CONNECTION_APPROVAL PROFILE_LIFECYCLE ALL SALES_REP_NOTIFICATIONS] Optional: - `send_interval` (String) Send interval - -### Nested Schema for `order` - -Optional: - -- `purchase_order_number` (String) Purchase order number - -Read-Only: - -- `billing_tier` (String) Billing tier for connection bandwidth -- `order_id` (String) Order Identification -- `order_number` (String) Order Reference Number - - ### Nested Schema for `z_side` @@ -942,18 +940,18 @@ Optional: - `link_protocol` (Block Set, Max: 1) Connection link protocol (see [below for nested schema](#nestedblock--z_side--access_point--link_protocol)) - `location` (Block Set, Max: 1) Access point location (see [below for nested schema](#nestedblock--z_side--access_point--location)) - `network` (Block Set, Max: 1) network access point information (see [below for nested schema](#nestedblock--z_side--access_point--network)) -- `peering_type` (String) Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL +- `peering_type` (String) Peering type. One of [PRIVATE MICROSOFT PUBLIC MANUAL] - `port` (Block Set, Max: 1) Port access point information (see [below for nested schema](#nestedblock--z_side--access_point--port)) - `profile` (Block Set, Max: 1) Service Profile (see [below for nested schema](#nestedblock--z_side--access_point--profile)) -- `provider_connection_id` (String) Provider assigned Connection Id - `router` (Block Set, Max: 1) Cloud Router access point information that replaces `gateway` (see [below for nested schema](#nestedblock--z_side--access_point--router)) - `seller_region` (String) Access point seller region -- `type` (String) Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK +- `type` (String) Access point type. One of [VD VG SP IGW COLO SUBNET CLOUD_ROUTER NETWORK METAL_NETWORK] - `virtual_device` (Block Set, Max: 1) Virtual device (see [below for nested schema](#nestedblock--z_side--access_point--virtual_device)) Read-Only: -- `account` (Block Set) Account (see [below for nested schema](#nestedblock--z_side--access_point--account)) +- `account` (Set of Object) Account (see [below for nested schema](#nestedatt--z_side--access_point--account)) +- `provider_connection_id` (String) Provider assigned Connection Id ### Nested Schema for `z_side.access_point.gateway` @@ -970,19 +968,28 @@ Read-Only: ### Nested Schema for `z_side.access_point.interface` +Required: + +- `type` (String) Interface type. One of [CLOUD NETWORK] + Optional: - `id` (Number) id -- `type` (String) Interface type + +Read-Only: + - `uuid` (String) Equinix-assigned interface identifier ### Nested Schema for `z_side.access_point.link_protocol` +Required: + +- `type` (String) Type of the link protocol. One of [UNTAGGED DOT1Q QINQ EVPN_VXLAN VXLAN] + Optional: -- `type` (String) Type of the link protocol - UNTAGGED, DOT1Q, QINQ, EVPN_VXLAN - `vlan_c_tag` (Number) Vlan Customer Tag information, vlanCTag value specified for QINQ connections - `vlan_s_tag` (Number) Vlan Provider Tag information, vlanSTag value specified for QINQ connections - `vlan_tag` (Number) Vlan Tag information, vlanTag value specified for DOT1Q connections @@ -991,10 +998,13 @@ Optional: ### Nested Schema for `z_side.access_point.location` -Optional: +Required: -- `ibx` (String) IBX Code - `metro_code` (String) Access point metro code + +Read-Only: + +- `ibx` (String) IBX Code - `metro_name` (String) Access point metro name - `region` (String) Access point region @@ -1002,7 +1012,7 @@ Optional: ### Nested Schema for `z_side.access_point.network` -Optional: +Required: - `uuid` (String) Equinix-assigned Network identifier @@ -1014,7 +1024,7 @@ Read-Only: ### Nested Schema for `z_side.access_point.port` -Optional: +Required: - `uuid` (String) Equinix-assigned Port identifier @@ -1040,7 +1050,7 @@ Read-Only: Required: -- `type` (String) Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE +- `type` (String) Service profile type. One of [L2_PROFILE L3_PROFILE IA_PROFILE] - `uuid` (String) Equinix assigned service profile identifier Read-Only: @@ -1075,37 +1085,37 @@ Read-Only: ### Nested Schema for `z_side.access_point.virtual_device` -Optional: +Required: -- `name` (String) Customer-assigned Virtual Device Name -- `type` (String) Virtual Device type +- `type` (String) Virtual Device type. One of [EDGE] - `uuid` (String) Equinix-assigned Virtual Device identifier Read-Only: - `href` (String) Unique Resource Identifier +- `name` (String) Customer-assigned Virtual Device Name - + ### Nested Schema for `z_side.access_point.account` Read-Only: -- `account_name` (String) Legal name of the accountholder. -- `account_number` (Number) Equinix-assigned account number. -- `global_cust_id` (String) Equinix-assigned ID of the subscriber's parent organization. -- `global_org_id` (String) Equinix-assigned ID of the subscriber's parent organization. -- `global_organization_name` (String) Equinix-assigned name of the subscriber's parent organization. -- `org_id` (Number) Equinix-assigned ID of the subscriber's organization. -- `organization_name` (String) Equinix-assigned name of the subscriber's organization. -- `ucm_id` (String) Enterprise datastore id +- `account_name` (String) +- `account_number` (Number) +- `global_cust_id` (String) +- `global_org_id` (String) +- `global_organization_name` (String) +- `org_id` (Number) +- `organization_name` (String) +- `ucm_id` (String) ### Nested Schema for `z_side.additional_info` -Optional: +Required: - `key` (String) Additional information key - `value` (String) Additional information value @@ -1116,7 +1126,7 @@ Optional: Optional: -- `type` (String) Token type - VC_TOKEN +- `type` (String) Token type. One of [VC_TOKEN] - `uuid` (String) Equinix-assigned service token identifier Read-Only: @@ -1126,16 +1136,26 @@ Read-Only: - -### Nested Schema for `project` + +### Nested Schema for `order` Optional: -- `project_id` (String) Project Id +- `purchase_order_number` (String) Purchase order number. Short name/number to identify this order on the invoice Read-Only: -- `href` (String) Unique Resource URL +- `billing_tier` (String) Billing tier for connection bandwidth +- `order_id` (String) Order Identification +- `order_number` (String) Order Reference Number + + + +### Nested Schema for `project` + +Required: + +- `project_id` (String) Project Id @@ -1144,7 +1164,7 @@ Read-Only: Optional: - `group` (String) Redundancy group identifier (Use the redundancy.0.group UUID of primary connection; e.g. one(equinix_fabric_connection.primary_port_connection.redundancy).group or equinix_fabric_connection.primary_port_connection.redundancy.0.group) -- `priority` (String) Connection priority in redundancy group - PRIMARY, SECONDARY +- `priority` (String) Connection priority in redundancy group. One of [PRIMARY SECONDARY] diff --git a/docs/resources/equinix_fabric_network.md b/docs/resources/equinix_fabric_network.md index 7f4a02739..fc7def424 100644 --- a/docs/resources/equinix_fabric_network.md +++ b/docs/resources/equinix_fabric_network.md @@ -38,9 +38,9 @@ resource "equinix_fabric_network" "new_network" { - `name` (String) Fabric Network name. An alpha-numeric 24 characters string which can include only hyphens and underscores - `notifications` (Block List, Min: 1) Preferences for notifications on Fabric Network configuration or status changes (see [below for nested schema](#nestedblock--notifications)) -- `project` (Block Set, Min: 1) Fabric Network project (see [below for nested schema](#nestedblock--project)) -- `scope` (String) Fabric Network scope -- `type` (String) Supported Network types - EVPLAN, EPLAN, IPWAN +- `project` (Block Set, Min: 1, Max: 1) Fabric Network project (see [below for nested schema](#nestedblock--project)) +- `scope` (String) Fabric Network scope. One of [REGIONAL GLOBAL LOCAL] +- `type` (String) Supported Network types. One of [REGIONAL GLOBAL LOCAL] ### Optional @@ -64,7 +64,7 @@ resource "equinix_fabric_network" "new_network" { Required: - `emails` (List of String) Array of contact emails -- `type` (String) Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS +- `type` (String) Notification type. One of [NOTIFICATION BANDWIDTH_ALERT CONNECTION_APPROVAL PROFILE_LIFECYCLE ALL SALES_REP_NOTIFICATIONS] Optional: @@ -76,7 +76,7 @@ Optional: Required: -- `project_id` (String) Customer project identifier +- `project_id` (String) Project Id diff --git a/docs/resources/equinix_fabric_routing_protocol.md b/docs/resources/equinix_fabric_routing_protocol.md index d1ed4f54d..3c3918d16 100644 --- a/docs/resources/equinix_fabric_routing_protocol.md +++ b/docs/resources/equinix_fabric_routing_protocol.md @@ -91,14 +91,14 @@ resource "equinix_fabric_routing_protocol" "bgp" { ### Optional -- `bfd` (Block Set) Bidirectional Forwarding Detection (see [below for nested schema](#nestedblock--bfd)) +- `bfd` (Block Set, Max: 1) Bidirectional Forwarding Detection (see [below for nested schema](#nestedblock--bfd)) - `bgp_auth_key` (String) BGP authorization key -- `bgp_ipv4` (Block Set) Routing Protocol BGP IPv4 (see [below for nested schema](#nestedblock--bgp_ipv4)) -- `bgp_ipv6` (Block Set) Routing Protocol BGP IPv6 (see [below for nested schema](#nestedblock--bgp_ipv6)) +- `bgp_ipv4` (Block Set, Max: 1) Routing Protocol BGP IPv4 (see [below for nested schema](#nestedblock--bgp_ipv4)) +- `bgp_ipv6` (Block Set, Max: 1) Routing Protocol BGP IPv6 (see [below for nested schema](#nestedblock--bgp_ipv6)) - `customer_asn` (Number) Customer-provided ASN - `description` (String) Customer-provided Fabric Routing Protocol description -- `direct_ipv4` (Block Set) Routing Protocol Direct IPv4 (see [below for nested schema](#nestedblock--direct_ipv4)) -- `direct_ipv6` (Block Set) Routing Protocol Direct IPv6 (see [below for nested schema](#nestedblock--direct_ipv6)) +- `direct_ipv4` (Block Set, Max: 1) Routing Protocol Direct IPv4 (see [below for nested schema](#nestedblock--direct_ipv4)) +- `direct_ipv6` (Block Set, Max: 1) Routing Protocol Direct IPv6 (see [below for nested schema](#nestedblock--direct_ipv6)) - `name` (String) Routing Protocol name. An alpha-numeric 24 characters string which can include only hyphens and underscores - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) - `type` (String) Defines the routing protocol type like BGP or DIRECT diff --git a/docs/resources/equinix_fabric_service_profile.md b/docs/resources/equinix_fabric_service_profile.md index 671577ff6..b6dd7242a 100644 --- a/docs/resources/equinix_fabric_service_profile.md +++ b/docs/resources/equinix_fabric_service_profile.md @@ -56,7 +56,7 @@ resource "equinix_fabric_service_profile" "new_service_profile" { - `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 +- `type` (String) Service profile type. One of [L2_PROFILE L3_PROFILE IA_PROFILE] ### Optional @@ -72,6 +72,7 @@ resource "equinix_fabric_service_profile" "new_service_profile" { - `state` (String) Service profile state - ACTIVE, PENDING_APPROVAL, DELETED, REJECTED - `tags` (List of String) Tags attached to the connection - `timeouts` (Block, Optional) (see [below for nested schema](#nestedblock--timeouts)) +- `view_point` (String) Flips view between buyer and seller representation. Available values : aSide, zSide. Default value : aSide - `virtual_devices` (Block List) Virtual Devices (see [below for nested schema](#nestedblock--virtual_devices)) - `visibility` (String) Service profile visibility - PUBLIC, PRIVATE @@ -88,7 +89,7 @@ resource "equinix_fabric_service_profile" "new_service_profile" { Required: -- `type` (String) Type of access point type config - VD, COLO +- `type` (String) Type of access point type config. One of [VD COLO] Optional: @@ -199,7 +200,7 @@ Optional: Required: - `emails` (List of String) Array of contact emails -- `type` (String) Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS +- `type` (String) Notification type. One of [NOTIFICATION BANDWIDTH_ALERT CONNECTION_APPROVAL PROFILE_LIFECYCLE ALL SALES_REP_NOTIFICATIONS] Optional: @@ -236,14 +237,10 @@ Optional: ### Nested Schema for `project` -Optional: +Required: - `project_id` (String) Project Id -Read-Only: - -- `href` (String) Unique Resource URL - ### Nested Schema for `timeouts` diff --git a/equinix/data_source_fabric_cloud_router.go b/equinix/data_source_fabric_cloud_router.go index e914f79ff..7b2b722ef 100644 --- a/equinix/data_source_fabric_cloud_router.go +++ b/equinix/data_source_fabric_cloud_router.go @@ -9,7 +9,7 @@ import ( func readFabricCloudRouterResourceSchema() map[string]*schema.Schema { sch := fabricCloudRouterResourceSchema() - for key, _ := range sch { + for key := range sch { if key == "uuid" { sch[key].Required = true sch[key].Optional = false diff --git a/equinix/data_source_fabric_connection.go b/equinix/data_source_fabric_connection.go index e6914f2fc..7c4be151f 100644 --- a/equinix/data_source_fabric_connection.go +++ b/equinix/data_source_fabric_connection.go @@ -8,7 +8,7 @@ import ( func readFabricConnectionResourceSchema() map[string]*schema.Schema { sch := fabricConnectionResourceSchema() - for key, _ := range sch { + for key := range sch { if key == "uuid" { sch[key].Required = true sch[key].Optional = false diff --git a/equinix/data_source_fabric_network.go b/equinix/data_source_fabric_network.go index 6b4a7c9b0..20b9e5375 100755 --- a/equinix/data_source_fabric_network.go +++ b/equinix/data_source_fabric_network.go @@ -9,7 +9,7 @@ import ( func readFabricNetworkResourceSchema() map[string]*schema.Schema { sch := fabricNetworkResourceSchema() - for key, _ := range sch { + for key := range sch { if key == "uuid" { sch[key].Required = true sch[key].Optional = false diff --git a/equinix/data_source_fabric_routing_protocol.go b/equinix/data_source_fabric_routing_protocol.go index 749a35a42..ee4b3eae3 100644 --- a/equinix/data_source_fabric_routing_protocol.go +++ b/equinix/data_source_fabric_routing_protocol.go @@ -9,7 +9,7 @@ import ( func readFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { sch := createFabricRoutingProtocolResourceSchema() - for key, _ := range sch { + for key := range sch { if key == "uuid" || key == "connection_uuid" { sch[key].Required = true sch[key].Optional = false diff --git a/equinix/data_source_fabric_service_profile.go b/equinix/data_source_fabric_service_profile.go index 13e05f71a..c3e9540c5 100644 --- a/equinix/data_source_fabric_service_profile.go +++ b/equinix/data_source_fabric_service_profile.go @@ -10,7 +10,7 @@ import ( func readFabricServiceProfileResourceSchema() map[string]*schema.Schema { sch := fabricServiceProfileSchema() - for key, _ := range sch { + for key := range sch { if key == "uuid" { sch[key].Required = true sch[key].Optional = false diff --git a/equinix/resource_fabric_cloud_router.go b/equinix/resource_fabric_cloud_router.go index 4c5dc0cd9..ab0459f7a 100644 --- a/equinix/resource_fabric_cloud_router.go +++ b/equinix/resource_fabric_cloud_router.go @@ -14,6 +14,7 @@ import ( equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" + equinix_validation "github.com/equinix/terraform-provider-equinix/internal/validation" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -25,35 +26,34 @@ func fabricCloudRouterPackageSch() map[string]*schema.Schema { "code": { Type: schema.TypeString, Required: true, - Description: "Fabric Cloud Router package code", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedRouterPackageCodeEnumValues, false), + Description: fmt.Sprintf("Fabric Cloud Router package code. One of %v", fabricv4.AllowedRouterPackageCodeEnumValues), }, } } + func fabricCloudRouterAccountSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "account_number": { Type: schema.TypeInt, - Computed: true, - Optional: true, + Required: true, Description: "Account Number", }, } } -func fabricCloudRouterProjectSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Computed: true, - Optional: true, - Description: "Project Id", - }, - "href": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Unique Resource URL", - }, + +func fabricCloudRouterlocationSch() map[string]*schema.Schema { + sch := equinix_fabric_schema.LocationSchWithoutIbx() + for key := range sch { + if key == "metro_code" { + sch[key].Required = true + sch[key].Optional = false + sch[key].Computed = false + } else { + sch[key].Optional = false + } } + return sch } func fabricCloudRouterResourceSchema() map[string]*schema.Schema { @@ -111,8 +111,8 @@ func fabricCloudRouterResourceSchema() map[string]*schema.Schema { "type": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"XF_ROUTER"}, true), - Description: "Defines the FCR type like; XF_ROUTER", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedCloudRouterPostRequestTypeEnumValues, true), + Description: fmt.Sprintf("Defines the FCR type. One of %v", fabricv4.AllowedCloudRouterPostRequestTypeEnumValues), }, "location": { Type: schema.TypeSet, @@ -120,7 +120,7 @@ func fabricCloudRouterResourceSchema() map[string]*schema.Schema { Description: "Fabric Cloud Router location", MaxItems: 1, Elem: &schema.Resource{ - Schema: equinix_fabric_schema.LocationSch(), + Schema: fabricCloudRouterlocationSch(), }, }, "project": { @@ -129,7 +129,7 @@ func fabricCloudRouterResourceSchema() map[string]*schema.Schema { Description: "Customer resource hierarchy project information. Applicable to customers onboarded to Equinix Identity and Access Management. For more information see Identity and Access Management: Projects", MaxItems: 1, Elem: &schema.Resource{ - Schema: fabricCloudRouterProjectSch(), + Schema: equinix_fabric_schema.ProjectSch(), }, }, "account": { @@ -221,7 +221,7 @@ func accountCloudRouterTerraformToGo(accountList []interface{}) fabricv4.Simplif } func packageCloudRouterTerraformToGo(packageList []interface{}) fabricv4.CloudRouterPostRequestPackage { - if packageList == nil || len(packageList) == 0 { + if len(packageList) == 0 { return fabricv4.CloudRouterPostRequestPackage{} } @@ -233,7 +233,7 @@ func packageCloudRouterTerraformToGo(packageList []interface{}) fabricv4.CloudRo return package_ } func projectCloudRouterTerraformToGo(projectTerraform []interface{}) fabricv4.Project { - if projectTerraform == nil || len(projectTerraform) == 0 { + if len(projectTerraform) == 0 { return fabricv4.Project{} } project := fabricv4.Project{} diff --git a/equinix/resource_fabric_connection.go b/equinix/resource_fabric_connection.go index 280b240bb..58c468fd0 100644 --- a/equinix/resource_fabric_connection.go +++ b/equinix/resource_fabric_connection.go @@ -10,6 +10,7 @@ import ( equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" + equinix_validation "github.com/equinix/terraform-provider-equinix/internal/validation" "github.com/equinix/terraform-provider-equinix/internal/config" @@ -25,8 +26,8 @@ func fabricConnectionResourceSchema() map[string]*schema.Schema { "type": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"EVPL_VC", "EPL_VC", "IP_VC", "IPWAN_VC", "ACCESS_EPL_VC", "EVPLAN_VC", "EPLAN_VC", "EIA_VC", "IA_VC", "EC_VC"}, false), - Description: "Defines the connection type like EVPL_VC, EPL_VC, IPWAN_VC, IP_VC, ACCESS_EPL_VC, EVPLAN_VC, EPLAN_VC, EIA_VC, IA_VC, EC_VC", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedConnectionTypeEnumValues, true), + Description: fmt.Sprintf("Defines the connection type. One of %v", fabricv4.AllowedConnectionTypeEnumValues), }, "name": { Type: schema.TypeString, @@ -66,10 +67,11 @@ func fabricConnectionResourceSchema() map[string]*schema.Schema { "redundancy": { Type: schema.TypeSet, Optional: true, + Computed: true, Description: "Connection Redundancy Configuration", MaxItems: 1, Elem: &schema.Resource{ - Schema: connectionRedundancySch(), + Schema: fabricConnectionRedundancySch(), }, }, "a_side": { @@ -77,16 +79,16 @@ func fabricConnectionResourceSchema() map[string]*schema.Schema { Required: true, Description: "Requester or Customer side connection configuration object of the multi-segment connection", MaxItems: 1, - Elem: connectionSideSch(), - Set: schema.HashResource(accessPointSch()), + Elem: fabricConnectionSideSch(), + Set: schema.HashResource(fabricConnectionAccessPointSch()), }, "z_side": { Type: schema.TypeSet, Required: true, Description: "Destination or Provider side connection configuration object of the multi-segment connection", MaxItems: 1, - Elem: connectionSideSch(), - Set: schema.HashResource(accessPointSch()), + Elem: fabricConnectionSideSch(), + Set: schema.HashResource(fabricConnectionAccessPointSch()), }, "project": { Type: schema.TypeSet, @@ -131,7 +133,7 @@ func fabricConnectionResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Connection type-specific operational data", Elem: &schema.Resource{ - Schema: operationSch(), + Schema: equinix_fabric_schema.OperationSch(), }, }, "account": { @@ -163,16 +165,17 @@ func fabricConnectionResourceSchema() map[string]*schema.Schema { } } -func connectionSideSch() *schema.Resource { +func fabricConnectionSideSch() *schema.Resource { return &schema.Resource{ Schema: map[string]*schema.Schema{ "service_token": { Type: schema.TypeSet, Optional: true, + ForceNew: 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", MaxItems: 1, Elem: &schema.Resource{ - Schema: serviceTokenSch(), + Schema: fabricConnectionServiceTokenSch(), }, }, "access_point": { @@ -180,27 +183,27 @@ func connectionSideSch() *schema.Resource { Optional: true, Description: "Point of access details", MaxItems: 1, - Elem: accessPointSch(), + Elem: fabricConnectionAccessPointSch(), }, "additional_info": { Type: schema.TypeList, Optional: true, Description: "Connection side additional information", Elem: &schema.Resource{ - Schema: additionalInfoSch(), + Schema: fabricConnectionAdditionalInfoSch(), }, }, }, } } -func serviceTokenSch() map[string]*schema.Schema { +func fabricConnectionServiceTokenSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "type": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringInSlice([]string{"VC_TOKEN"}, true), - Description: "Token type - VC_TOKEN", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedServiceTokenTypeEnumValues, true), + Description: fmt.Sprintf("Token type. One of %v", fabricv4.AllowedServiceTokenTypeEnumValues), }, "href": { Type: schema.TypeString, @@ -220,20 +223,20 @@ func serviceTokenSch() map[string]*schema.Schema { } } -func accessPointSch() *schema.Resource { +func fabricConnectionAccessPointSch() *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", "CLOUD_ROUTER", "NETWORK", "METAL_NETWORK"}, true), - Description: "Access point type - COLO, VD, VG, SP, IGW, SUBNET, CLOUD_ROUTER, NETWORK", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedAccessPointTypeEnumValues, true), + Description: fmt.Sprintf("Access point type. One of %v", fabricv4.AllowedAccessPointTypeEnumValues), }, "account": { Type: schema.TypeSet, - Optional: true, Computed: true, Description: "Account", + MaxItems: 1, Elem: &schema.Resource{ Schema: equinix_fabric_schema.AccountSch(), }, @@ -245,7 +248,7 @@ func accessPointSch() *schema.Resource { Description: "Access point location", MaxItems: 1, Elem: &schema.Resource{ - Schema: equinix_fabric_schema.LocationSch(), + Schema: fabricConnectionLocationSch(), }, }, "port": { @@ -254,7 +257,7 @@ func accessPointSch() *schema.Resource { Description: "Port access point information", MaxItems: 1, Elem: &schema.Resource{ - Schema: portSch(), + Schema: equinix_fabric_schema.PortSch(), }, }, "profile": { @@ -263,7 +266,7 @@ func accessPointSch() *schema.Resource { Description: "Service Profile", MaxItems: 1, Elem: &schema.Resource{ - Schema: serviceProfileSch(), + Schema: fabricConnectionServiceProfileSch(), }, }, "gateway": { @@ -273,7 +276,7 @@ func accessPointSch() *schema.Resource { Description: "**Deprecated** `gateway` Use `router` attribute instead", MaxItems: 1, Elem: &schema.Resource{ - Schema: cloudRouterSch(), + Schema: fabricConnectionCloudRouterSch(), }, }, "router": { @@ -282,7 +285,7 @@ func accessPointSch() *schema.Resource { Description: "Cloud Router access point information that replaces `gateway`", MaxItems: 1, Elem: &schema.Resource{ - Schema: cloudRouterSch(), + Schema: fabricConnectionCloudRouterSch(), }, }, "link_protocol": { @@ -291,7 +294,7 @@ func accessPointSch() *schema.Resource { Description: "Connection link protocol", MaxItems: 1, Elem: &schema.Resource{ - Schema: accessPointLinkProtocolSch(), + Schema: fabricConnectionAccessPointLinkProtocolSch(), }, }, "virtual_device": { @@ -300,7 +303,7 @@ func accessPointSch() *schema.Resource { Description: "Virtual device", MaxItems: 1, Elem: &schema.Resource{ - Schema: accessPointVirtualDeviceSch(), + Schema: fabricConnectionAccessPointVirtualDeviceSch(), }, }, "interface": { @@ -309,7 +312,7 @@ func accessPointSch() *schema.Resource { Description: "Virtual device interface", MaxItems: 1, Elem: &schema.Resource{ - Schema: accessPointInterface(), + Schema: fabricConnectionAccessPointInterfaceSch(), }, }, "network": { @@ -318,7 +321,7 @@ func accessPointSch() *schema.Resource { Description: "network access point information", MaxItems: 1, Elem: &schema.Resource{ - Schema: networkSch(), + Schema: fabricConnectionAccessPointNetworkSch(), }, }, "seller_region": { @@ -329,8 +332,8 @@ func accessPointSch() *schema.Resource { "peering_type": { Type: schema.TypeString, Optional: true, - ValidateFunc: validation.StringInSlice([]string{"PRIVATE", "MICROSOFT", "PUBLIC", "MANUAL"}, true), - Description: "Peering Type- PRIVATE,MICROSOFT,PUBLIC, MANUAL", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedPeeringTypeEnumValues, true), + Description: fmt.Sprintf("Peering type. One of %v", fabricv4.AllowedPeeringTypeEnumValues), }, "authentication_key": { Type: schema.TypeString, @@ -346,7 +349,21 @@ func accessPointSch() *schema.Resource { } } -func serviceProfileSch() map[string]*schema.Schema { +func fabricConnectionLocationSch() map[string]*schema.Schema { + sch := equinix_fabric_schema.LocationSch() + for key := range sch { + if key == "metro_code" { + sch[key].Required = true + sch[key].Optional = false + sch[key].Computed = false + } else { + sch[key].Optional = false + } + } + return sch +} + +func fabricConnectionServiceProfileSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "href": { Type: schema.TypeString, @@ -356,8 +373,8 @@ func serviceProfileSch() map[string]*schema.Schema { "type": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"L2_PROFILE", "L3_PROFILE", "ECIA_PROFILE", "ECMC_PROFILE", "IA_PROFILE"}, true), - Description: "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE, IA_PROFILE", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedServiceProfileTypeEnumEnumValues, true), + Description: fmt.Sprintf("Service profile type. One of %v", fabricv4.AllowedServiceProfileTypeEnumEnumValues), }, "name": { Type: schema.TypeString, @@ -379,13 +396,13 @@ func serviceProfileSch() map[string]*schema.Schema { Computed: true, Description: "Access point config information", Elem: &schema.Resource{ - Schema: connectionAccessPointTypeConfigSch(), + Schema: fabricConnectionAccessPointTypeConfigSch(), }, }, } } -func cloudRouterSch() map[string]*schema.Schema { +func fabricConnectionCloudRouterSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "uuid": { Type: schema.TypeString, @@ -400,13 +417,13 @@ func cloudRouterSch() map[string]*schema.Schema { } } -func accessPointLinkProtocolSch() map[string]*schema.Schema { +func fabricConnectionAccessPointLinkProtocolSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "type": { Type: schema.TypeString, - Optional: true, - Description: "Type of the link protocol - UNTAGGED, DOT1Q, QINQ, EVPN_VXLAN", - ValidateFunc: validation.StringInSlice([]string{"UNTAGGED", "DOT1Q", "QINQ", "EVPN_VXLAN"}, true), + Required: true, + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedLinkProtocolTypeEnumValues, true), + Description: fmt.Sprintf("Type of the link protocol. One of %v", fabricv4.AllowedLinkProtocolTypeEnumValues), }, "vlan_tag": { Type: schema.TypeInt, @@ -429,7 +446,7 @@ func accessPointLinkProtocolSch() map[string]*schema.Schema { } } -func accessPointVirtualDeviceSch() map[string]*schema.Schema { +func fabricConnectionAccessPointVirtualDeviceSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "href": { Type: schema.TypeString, @@ -438,27 +455,28 @@ func accessPointVirtualDeviceSch() map[string]*schema.Schema { }, "uuid": { Type: schema.TypeString, - Optional: true, + Required: true, Description: "Equinix-assigned Virtual Device identifier", }, "type": { Type: schema.TypeString, - Optional: true, - Description: "Virtual Device type", + Required: true, + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedVirtualDeviceTypeEnumValues, true), + Description: fmt.Sprintf("Virtual Device type. One of %v", fabricv4.AllowedVirtualDeviceTypeEnumValues), }, "name": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Customer-assigned Virtual Device Name", }, } } -func accessPointInterface() map[string]*schema.Schema { +func fabricConnectionAccessPointInterfaceSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "uuid": { Type: schema.TypeString, - Optional: true, + Computed: true, Description: "Equinix-assigned interface identifier", }, "id": { @@ -469,17 +487,18 @@ func accessPointInterface() map[string]*schema.Schema { }, "type": { Type: schema.TypeString, - Optional: true, - Description: "Interface type", + Required: true, + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedInterfaceTypeEnumValues, true), + Description: fmt.Sprintf("Interface type. One of %v", fabricv4.AllowedInterfaceTypeEnumValues), }, } } -func networkSch() map[string]*schema.Schema { +func fabricConnectionAccessPointNetworkSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "uuid": { Type: schema.TypeString, - Optional: true, + Required: true, Description: "Equinix-assigned Network identifier", }, "href": { @@ -490,41 +509,14 @@ func networkSch() map[string]*schema.Schema { } } -func portSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "uuid": { - Type: schema.TypeString, - Optional: true, - Computed: true, - Description: "Equinix-assigned Port identifier", - }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource Identifier", - }, - "name": { - Type: schema.TypeString, - Computed: true, - Description: "Port name", - }, - "redundancy": { - Type: schema.TypeSet, - Computed: true, - Description: "Redundancy Information", - Elem: &schema.Resource{ - Schema: PortRedundancySch(), - }, - }, - } -} -func connectionAccessPointTypeConfigSch() map[string]*schema.Schema { + +func fabricConnectionAccessPointTypeConfigSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "type": { Type: schema.TypeString, Computed: true, - Description: "Type of access point type config - VD, COLO", + Description: fmt.Sprintf("Type of access point type config. One of %v", fabricv4.AllowedServiceProfileAccessPointTypeEnumEnumValues), }, "uuid": { Type: schema.TypeString, @@ -534,45 +526,22 @@ func connectionAccessPointTypeConfigSch() map[string]*schema.Schema { } } -func additionalInfoSch() map[string]*schema.Schema { +func fabricConnectionAdditionalInfoSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "key": { Type: schema.TypeString, - Optional: true, + Required: true, Description: "Additional information key", }, "value": { Type: schema.TypeString, - Optional: true, + Required: true, Description: "Additional information value", }, } } -func operationSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "provider_status": { - Type: schema.TypeString, - Computed: true, - Description: "Connection provider readiness status", - }, - "equinix_status": { - Type: schema.TypeString, - Computed: true, - Description: "Connection status", - }, - "errors": { - Type: schema.TypeList, - Computed: true, - Description: "Errors occurred", - Elem: &schema.Resource{ - Schema: equinix_fabric_schema.ErrorSch(), - }, - }, - } -} - -func connectionRedundancySch() map[string]*schema.Schema { +func fabricConnectionRedundancySch() map[string]*schema.Schema { return map[string]*schema.Schema{ "group": { Type: schema.TypeString, @@ -584,8 +553,8 @@ func connectionRedundancySch() map[string]*schema.Schema { Type: schema.TypeString, Computed: true, Optional: true, - ValidateFunc: validation.StringInSlice([]string{"PRIMARY", "SECONDARY"}, true), - Description: "Connection priority in redundancy group - PRIMARY, SECONDARY", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedConnectionPriorityEnumValues, true), + Description: fmt.Sprintf("Connection priority in redundancy group. One of %v", fabricv4.AllowedConnectionPriorityEnumValues), }, } } @@ -705,11 +674,11 @@ func additionalInfoContainsAWSSecrets(info []interface{}) ([]interface{}, bool) var awsSecrets []interface{} for _, item := range info { - if value, _ := item.(map[string]interface{})["key"]; value == "accessKey" { + if value := item.(map[string]interface{})["key"]; value == "accessKey" { awsSecrets = append(awsSecrets, item) } - if value, _ := item.(map[string]interface{})["key"]; value == "secretKey" { + if value := item.(map[string]interface{})["key"]; value == "secretKey" { awsSecrets = append(awsSecrets, item) } } @@ -765,14 +734,13 @@ func setFabricMap(d *schema.ResourceData, conn *fabricv4.Connection) diag.Diagno account := conn.GetAccount() connection["account"] = equinix_fabric_schema.AccountGoToTerraform(&account) } - if &conn.ASide != nil { - aSide := conn.GetASide() - connection["a_side"] = connectionSideGoToTerraform(&aSide) - } - if &conn.ZSide != nil { - zSide := conn.GetZSide() - connection["z_side"] = connectionSideGoToTerraform(&zSide) - } + + aSide := conn.GetASide() + connection["a_side"] = connectionSideGoToTerraform(&aSide) + + zSide := conn.GetZSide() + connection["z_side"] = connectionSideGoToTerraform(&zSide) + if conn.AdditionalInfo != nil { additionalInfo := conn.GetAdditionalInfo() connection["additional_info"] = additionalInfoGoToTerraform(additionalInfo) @@ -1017,7 +985,7 @@ func WaitUntilConnectionDeprovisioned(uuid string, meta interface{}, d *schema.R } func connectionRedundancyTerraformToGo(redundancyTerraform []interface{}) fabricv4.ConnectionRedundancy { - if redundancyTerraform == nil || len(redundancyTerraform) == 0 { + if len(redundancyTerraform) == 0 { return fabricv4.ConnectionRedundancy{} } var redundancy fabricv4.ConnectionRedundancy @@ -1041,14 +1009,14 @@ func connectionRedundancyGoToTerraform(redundancy *fabricv4.ConnectionRedundancy mappedRedundancy["group"] = redundancy.GetGroup() mappedRedundancy["priority"] = string(redundancy.GetPriority()) redundancySet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: connectionRedundancySch()}), + schema.HashResource(&schema.Resource{Schema: fabricConnectionRedundancySch()}), []interface{}{mappedRedundancy}, ) return redundancySet } func serviceTokenTerraformToGo(serviceTokenList []interface{}) fabricv4.ServiceToken { - if serviceTokenList == nil || len(serviceTokenList) == 0 { + if len(serviceTokenList) == 0 { return fabricv4.ServiceToken{} } @@ -1063,7 +1031,7 @@ func serviceTokenTerraformToGo(serviceTokenList []interface{}) fabricv4.ServiceT } func additionalInfoTerraformToGo(additionalInfoList []interface{}) []fabricv4.ConnectionSideAdditionalInfo { - if additionalInfoList == nil || len(additionalInfoList) == 0 { + if len(additionalInfoList) == 0 { return nil } @@ -1082,7 +1050,7 @@ func additionalInfoTerraformToGo(additionalInfoList []interface{}) []fabricv4.Co } func connectionSideTerraformToGo(connectionSideTerraform []interface{}) fabricv4.ConnectionSide { - if connectionSideTerraform == nil || len(connectionSideTerraform) == 0 { + if len(connectionSideTerraform) == 0 { return fabricv4.ConnectionSide{} } @@ -1109,7 +1077,7 @@ func connectionSideTerraformToGo(connectionSideTerraform []interface{}) fabricv4 } func accessPointTerraformToGo(accessPointTerraform []interface{}) fabricv4.AccessPoint { - if accessPointTerraform == nil || len(accessPointTerraform) == 0 { + if len(accessPointTerraform) == 0 { return fabricv4.AccessPoint{} } @@ -1200,7 +1168,7 @@ func accessPointTerraformToGo(accessPointTerraform []interface{}) fabricv4.Acces } func cloudRouterTerraformToGo(cloudRouterRequest []interface{}) fabricv4.CloudRouter { - if cloudRouterRequest == nil || len(cloudRouterRequest) == 0 { + if len(cloudRouterRequest) == 0 { return fabricv4.CloudRouter{} } var cloudRouter fabricv4.CloudRouter @@ -1212,7 +1180,7 @@ func cloudRouterTerraformToGo(cloudRouterRequest []interface{}) fabricv4.CloudRo } func linkProtocolTerraformToGo(linkProtocolList []interface{}) fabricv4.SimplifiedLinkProtocol { - if linkProtocolList == nil || len(linkProtocolList) == 0 { + if len(linkProtocolList) == 0 { return fabricv4.SimplifiedLinkProtocol{} } @@ -1239,7 +1207,7 @@ func linkProtocolTerraformToGo(linkProtocolList []interface{}) fabricv4.Simplifi } func networkTerraformToGo(networkList []interface{}) fabricv4.SimplifiedNetwork { - if networkList == nil || len(networkList) == 0 { + if len(networkList) == 0 { return fabricv4.SimplifiedNetwork{} } var network fabricv4.SimplifiedNetwork @@ -1250,7 +1218,7 @@ func networkTerraformToGo(networkList []interface{}) fabricv4.SimplifiedNetwork } func simplifiedServiceProfileTerraformToGo(profileList []interface{}) fabricv4.SimplifiedServiceProfile { - if profileList == nil || len(profileList) == 0 { + if len(profileList) == 0 { return fabricv4.SimplifiedServiceProfile{} } @@ -1264,7 +1232,7 @@ func simplifiedServiceProfileTerraformToGo(profileList []interface{}) fabricv4.S } func virtualDeviceTerraformToGo(virtualDeviceList []interface{}) fabricv4.VirtualDevice { - if virtualDeviceList == nil || len(virtualDeviceList) == 0 { + if len(virtualDeviceList) == 0 { return fabricv4.VirtualDevice{} } @@ -1283,7 +1251,7 @@ func virtualDeviceTerraformToGo(virtualDeviceList []interface{}) fabricv4.Virtua } func interfaceTerraformToGo(interfaceList []interface{}) fabricv4.Interface { - if interfaceList == nil || len(interfaceList) == 0 { + if len(interfaceList) == 0 { return fabricv4.Interface{} } @@ -1310,11 +1278,10 @@ func connectionOperationGoToTerraform(operation *fabricv4.ConnectionOperation) * if operation.Errors != nil { mappedOperation["errors"] = equinix_fabric_schema.ErrorGoToTerraform(operation.GetErrors()) } - operationSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: operationSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: equinix_fabric_schema.OperationSch()}), []interface{}{mappedOperation}, ) - return operationSet } func serviceTokenGoToTerraform(serviceToken *fabricv4.ServiceToken) *schema.Set { @@ -1328,11 +1295,10 @@ func serviceTokenGoToTerraform(serviceToken *fabricv4.ServiceToken) *schema.Set mappedServiceToken["href"] = serviceToken.GetHref() mappedServiceToken["uuid"] = serviceToken.GetUuid() - serviceTokenSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: serviceTokenSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: fabricConnectionServiceTokenSch()}), []interface{}{mappedServiceToken}, ) - return serviceTokenSet } func connectionSideGoToTerraform(connectionSide *fabricv4.ConnectionSide) *schema.Set { @@ -1344,11 +1310,11 @@ func connectionSideGoToTerraform(connectionSide *fabricv4.ConnectionSide) *schem } accessPoint := connectionSide.GetAccessPoint() mappedConnectionSide["access_point"] = accessPointGoToTerraform(&accessPoint) - connectionSideSet := schema.NewSet( - schema.HashResource(connectionSideSch()), + + return schema.NewSet( + schema.HashResource(fabricConnectionSideSch()), []interface{}{mappedConnectionSide}, ) - return connectionSideSet } func additionalInfoGoToTerraform(additionalInfo []fabricv4.ConnectionSideAdditionalInfo) []map[string]interface{} { @@ -1373,10 +1339,9 @@ func cloudRouterGoToTerraform(cloudRouter *fabricv4.CloudRouter) *schema.Set { mappedCloudRouter["uuid"] = cloudRouter.GetUuid() mappedCloudRouter["href"] = cloudRouter.GetHref() - linkedProtocolSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: equinix_fabric_schema.ProjectSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: fabricConnectionCloudRouterSch()}), []interface{}{mappedCloudRouter}) - return linkedProtocolSet } func virtualDeviceGoToTerraform(virtualDevice *fabricv4.VirtualDevice) *schema.Set { @@ -1389,10 +1354,9 @@ func virtualDeviceGoToTerraform(virtualDevice *fabricv4.VirtualDevice) *schema.S mappedVirtualDevice["type"] = string(virtualDevice.GetType()) mappedVirtualDevice["uuid"] = virtualDevice.GetUuid() - virtualDeviceSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: accessPointVirtualDeviceSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: fabricConnectionAccessPointVirtualDeviceSch()}), []interface{}{mappedVirtualDevice}) - return virtualDeviceSet } func interfaceGoToTerraform(mInterface *fabricv4.Interface) *schema.Set { @@ -1404,10 +1368,9 @@ func interfaceGoToTerraform(mInterface *fabricv4.Interface) *schema.Set { mappedMInterface["type"] = string(mInterface.GetType()) mappedMInterface["uuid"] = mInterface.GetUuid() - mInterfaceSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: accessPointInterface()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: fabricConnectionAccessPointInterfaceSch()}), []interface{}{mappedMInterface}) - return mInterfaceSet } func networkGoToTerraform(network *fabricv4.SimplifiedNetwork) *schema.Set { @@ -1419,7 +1382,7 @@ func networkGoToTerraform(network *fabricv4.SimplifiedNetwork) *schema.Set { mappedNetwork["uuid"] = network.GetUuid() return schema.NewSet( - schema.HashResource(&schema.Resource{Schema: networkSch()}), + schema.HashResource(&schema.Resource{Schema: fabricConnectionAccessPointNetworkSch()}), []interface{}{mappedNetwork}) } @@ -1472,11 +1435,10 @@ func accessPointGoToTerraform(accessPoint *fabricv4.AccessPoint) *schema.Set { mappedAccessPoint["authentication_key"] = accessPoint.GetAuthenticationKey() mappedAccessPoint["provider_connection_id"] = accessPoint.GetProviderConnectionId() - accessPointSet := schema.NewSet( - schema.HashResource(accessPointSch()), + return schema.NewSet( + schema.HashResource(fabricConnectionAccessPointSch()), []interface{}{mappedAccessPoint}, ) - return accessPointSet } func linkedProtocolGoToTerraform(linkedProtocol *fabricv4.SimplifiedLinkProtocol) *schema.Set { @@ -1487,10 +1449,9 @@ func linkedProtocolGoToTerraform(linkedProtocol *fabricv4.SimplifiedLinkProtocol mappedLinkedProtocol["vlan_s_tag"] = int(linkedProtocol.GetVlanSTag()) mappedLinkedProtocol["vlan_c_tag"] = int(linkedProtocol.GetVlanCTag()) - linkedProtocolSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: accessPointLinkProtocolSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: fabricConnectionAccessPointLinkProtocolSch()}), []interface{}{mappedLinkedProtocol}) - return linkedProtocolSet } func simplifiedServiceProfileGoToTerraform(profile *fabricv4.SimplifiedServiceProfile) *schema.Set { @@ -1502,11 +1463,10 @@ func simplifiedServiceProfileGoToTerraform(profile *fabricv4.SimplifiedServicePr mappedProfile["uuid"] = profile.GetName() mappedProfile["access_point_type_configs"] = accessPointTypeConfigGoToTerraform(profile.AccessPointTypeConfigs) - profileSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: serviceProfileSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: fabricConnectionServiceProfileSch()}), []interface{}{mappedProfile}, ) - return profileSet } func getUpdateRequests(conn *fabricv4.Connection, d *schema.ResourceData) ([][]fabricv4.ConnectionChangeOperation, error) { diff --git a/equinix/resource_fabric_network.go b/equinix/resource_fabric_network.go index 60c0a1fc2..dd752007d 100755 --- a/equinix/resource_fabric_network.go +++ b/equinix/resource_fabric_network.go @@ -8,11 +8,11 @@ import ( equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" + equinix_validation "github.com/equinix/terraform-provider-equinix/internal/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" - "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" - "github.com/hashicorp/terraform-plugin-testing/helper/resource" "log" "time" ) @@ -45,15 +45,7 @@ func fabricNetworkOperationSch() map[string]*schema.Schema { }, } } -func fabricNetworkProjectSch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "project_id": { - Type: schema.TypeString, - Required: true, - Description: "Customer project identifier", - }, - } -} + func fabricNetworkResourceSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "href": { @@ -80,13 +72,14 @@ func fabricNetworkResourceSchema() map[string]*schema.Schema { "scope": { Type: schema.TypeString, Required: true, - Description: "Fabric Network scope", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedNetworkScopeEnumValues, false), + Description: fmt.Sprintf("Fabric Network scope. One of %v", fabricv4.AllowedNetworkScopeEnumValues), }, "type": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"IPWAN", "EPLAN", "EVPLAN"}, true), - Description: "Supported Network types - EVPLAN, EPLAN, IPWAN", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedNetworkTypeEnumValues, true), + Description: fmt.Sprintf("Supported Network types. One of %v", fabricv4.AllowedNetworkScopeEnumValues), }, "location": { Type: schema.TypeSet, @@ -102,8 +95,9 @@ func fabricNetworkResourceSchema() map[string]*schema.Schema { Type: schema.TypeSet, Required: true, Description: "Fabric Network project", + MaxItems: 1, Elem: &schema.Resource{ - Schema: fabricNetworkProjectSch(), + Schema: equinix_fabric_schema.ProjectSch(), }, }, "operation": { @@ -145,6 +139,7 @@ func fabricNetworkResourceSchema() map[string]*schema.Schema { }, } } + func resourceFabricNetwork() *schema.Resource { return &schema.Resource{ Timeouts: &schema.ResourceTimeout{ @@ -166,6 +161,8 @@ func resourceFabricNetwork() *schema.Resource { } } + + func resourceFabricNetworkCreate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { client := meta.(*config.Config).NewFabricClientForSDK(d) createRequest := fabricv4.NetworkPostRequest{} @@ -222,12 +219,12 @@ func fabricNetworkOperationGoToTerraform(operation *fabricv4.NetworkOperation) * mappedOperation := make(map[string]interface{}) mappedOperation["equinix_status"] = string(*operation.EquinixStatus) - operationSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: fabricNetworkOperationSch()}), []interface{}{mappedOperation}, ) - return operationSet } + func simplifiedFabricNetworkChangeGoToTerraform(networkChange *fabricv4.SimplifiedNetworkChange) *schema.Set { mappedChange := make(map[string]interface{}) @@ -235,11 +232,10 @@ func simplifiedFabricNetworkChangeGoToTerraform(networkChange *fabricv4.Simplifi mappedChange["type"] = string(networkChange.GetType()) mappedChange["uuid"] = networkChange.GetUuid() - changeSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: fabricNetworkChangeSch()}), []interface{}{mappedChange}, ) - return changeSet } func setFabricNetworkMap(d *schema.ResourceData, nt *fabricv4.Network) diag.Diagnostics { @@ -316,7 +312,7 @@ func resourceFabricNetworkUpdate(ctx context.Context, d *schema.ResourceData, me func waitForFabricNetworkUpdateCompletion(uuid string, meta interface{}, d *schema.ResourceData, ctx context.Context, timeout time.Duration) (*fabricv4.Network, error) { log.Printf("Waiting for Network update to complete, uuid %s", uuid) - stateConf := &resource.StateChangeConf{ + stateConf := &retry.StateChangeConf{ Target: []string{string(fabricv4.NETWORKEQUINIXSTATUS_PROVISIONED)}, Refresh: func() (interface{}, string, error) { client := meta.(*config.Config).NewFabricClientForSDK(d) @@ -342,7 +338,7 @@ func waitForFabricNetworkUpdateCompletion(uuid string, meta interface{}, d *sche func waitUntilFabricNetworkIsProvisioned(uuid string, meta interface{}, d *schema.ResourceData, ctx context.Context, timeout time.Duration) (*fabricv4.Network, error) { log.Printf("Waiting for Fabric Network to be provisioned, uuid %s", uuid) - stateConf := &resource.StateChangeConf{ + stateConf := &retry.StateChangeConf{ Pending: []string{ string(fabricv4.NETWORKEQUINIXSTATUS_PROVISIONING), }, @@ -398,7 +394,7 @@ func resourceFabricNetworkDelete(ctx context.Context, d *schema.ResourceData, me func WaitUntilFabricNetworkDeprovisioned(uuid string, meta interface{}, d *schema.ResourceData, ctx context.Context, timeout time.Duration) error { log.Printf("Waiting for Fabric Network to be deprovisioned, uuid %s", uuid) - stateConf := &resource.StateChangeConf{ + stateConf := &retry.StateChangeConf{ Pending: []string{ string(fabricv4.NETWORKEQUINIXSTATUS_DEPROVISIONING), }, diff --git a/equinix/resource_fabric_network_acc_test.go b/equinix/resource_fabric_network_acc_test.go index 8d0e76984..7615781c6 100644 --- a/equinix/resource_fabric_network_acc_test.go +++ b/equinix/resource_fabric_network_acc_test.go @@ -124,7 +124,7 @@ func TestAccFabricNetworkCreateMixedParameters_PFCR(t *testing.T) { }) } func testAccNetworkCreateMixedParameterConfig_PFCR() string { - return fmt.Sprintf(` + return ` resource "equinix_fabric_network" "example2" { type = "IPWAN" name = "Tf_Network_PFCR" @@ -140,5 +140,5 @@ func testAccNetworkCreateMixedParameterConfig_PFCR() string { project_id = "291639000636552" } } -`) +` } diff --git a/equinix/resource_fabric_port.go b/equinix/resource_fabric_port.go index 5130f363e..8ca39f2be 100644 --- a/equinix/resource_fabric_port.go +++ b/equinix/resource_fabric_port.go @@ -31,7 +31,7 @@ func portDeviceSch() map[string]*schema.Schema { Computed: true, Description: "Port device redundancy", Elem: &schema.Resource{ - Schema: PortRedundancySch(), + Schema: equinix_fabric_schema.PortRedundancySch(), }, }, } @@ -72,26 +72,6 @@ func portOperationSch() map[string]*schema.Schema { } } -func PortRedundancySch() map[string]*schema.Schema { - return map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Computed: true, - Description: "Access point redundancy", - }, - "group": { - Type: schema.TypeString, - Computed: true, - Description: "Port redundancy group", - }, - "priority": { - Type: schema.TypeString, - Computed: true, - Description: "Priority type-Primary or Secondary", - }, - } -} - func FabricPortResourceSchema() map[string]*schema.Schema { return map[string]*schema.Schema{ "type": { @@ -189,7 +169,7 @@ func FabricPortResourceSchema() map[string]*schema.Schema { Computed: true, Description: "Port redundancy information", Elem: &schema.Resource{ - Schema: PortRedundancySch(), + Schema: equinix_fabric_schema.PortRedundancySch(), }, }, "encapsulation": { @@ -208,7 +188,7 @@ func FabricPortResourceSchema() map[string]*schema.Schema { } } -func readFabricPortResourceSchemaUpdated() map[string]*schema.Schema { +func readFabricPortResourceSch() map[string]*schema.Schema { sch := FabricPortResourceSchema() sch["uuid"].Computed = true sch["uuid"].Optional = false @@ -223,7 +203,7 @@ func readFabricPortsResponseSchema() map[string]*schema.Schema { Computed: true, Description: "List of Ports", Elem: &schema.Resource{ - Schema: readFabricPortResourceSchemaUpdated(), + Schema: readFabricPortResourceSch(), }, }, "filters": { @@ -249,7 +229,7 @@ func readGetPortsByNameQueryParamSch() map[string]*schema.Schema { } func portTerraformToGo(portList []interface{}) fabricv4.SimplifiedPort { - if portList == nil || len(portList) == 0 { + if len(portList) == 0 { return fabricv4.SimplifiedPort{} } var port fabricv4.SimplifiedPort @@ -268,11 +248,10 @@ func portGoToTerraform(port *fabricv4.SimplifiedPort) *schema.Set { if port.Redundancy != nil { mappedPort["redundancy"] = portRedundancyGoToTerraform(port.Redundancy) } - portSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: portSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: equinix_fabric_schema.PortSch()}), []interface{}{mappedPort}, ) - return portSet } func portRedundancyGoToTerraform(redundancy *fabricv4.PortRedundancy) *schema.Set { @@ -284,11 +263,10 @@ func portRedundancyGoToTerraform(redundancy *fabricv4.PortRedundancy) *schema.Se mappedRedundancy["group"] = redundancy.GetGroup() mappedRedundancy["priority"] = string(redundancy.GetPriority()) - redundancySet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: PortRedundancySch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: equinix_fabric_schema.PortRedundancySch()}), []interface{}{mappedRedundancy}, ) - return redundancySet } func portOperationGoToTerraform(operation *fabricv4.PortOperation) *schema.Set { @@ -301,11 +279,10 @@ func portOperationGoToTerraform(operation *fabricv4.PortOperation) *schema.Set { mappedOperation["connection_count"] = operation.GetConnectionCount() mappedOperation["op_status_changed_at"] = operation.GetOpStatusChangedAt().String() - operationSet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: operationSch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: equinix_fabric_schema.OperationSch()}), []interface{}{mappedOperation}, ) - return operationSet } func portDeviceRedundancyGoToTerraform(redundancy *fabricv4.PortDeviceRedundancy) *schema.Set { @@ -317,11 +294,10 @@ func portDeviceRedundancyGoToTerraform(redundancy *fabricv4.PortDeviceRedundancy mappedRedundancy["group"] = redundancy.GetGroup() mappedRedundancy["priority"] = string(redundancy.GetPriority()) - redundancySet := schema.NewSet( - schema.HashResource(&schema.Resource{Schema: PortRedundancySch()}), + return schema.NewSet( + schema.HashResource(&schema.Resource{Schema: equinix_fabric_schema.PortRedundancySch()}), []interface{}{mappedRedundancy}, ) - return redundancySet } func portDeviceGoToTerraform(device *fabricv4.PortDevice) *schema.Set { @@ -332,15 +308,12 @@ func portDeviceGoToTerraform(device *fabricv4.PortDevice) *schema.Set { mappedDevice := make(map[string]interface{}) mappedDevice["name"] = device.GetName() redundancy := device.GetRedundancy() - if &redundancy != nil { - mappedDevice["redundancy"] = portDeviceRedundancyGoToTerraform(&redundancy) - } + mappedDevice["redundancy"] = portDeviceRedundancyGoToTerraform(&redundancy) - deviceSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: portDeviceSch()}), []interface{}{mappedDevice}, ) - return deviceSet } func portEncapsulationGoToTerraform(portEncapsulation *fabricv4.PortEncapsulation) *schema.Set { @@ -352,11 +325,10 @@ func portEncapsulationGoToTerraform(portEncapsulation *fabricv4.PortEncapsulatio mappedPortEncapsulation["type"] = string(portEncapsulation.GetType()) mappedPortEncapsulation["tag_protocol_id"] = portEncapsulation.GetTagProtocolId() - portEncapsulationSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: portEncapsulationSch()}), []interface{}{mappedPortEncapsulation}, ) - return portEncapsulationSet } func resourceFabricPortRead(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { diff --git a/equinix/resource_fabric_port_acc_test.go b/equinix/resource_fabric_port_acc_test.go index 9b817a0fb..de74ce41c 100644 --- a/equinix/resource_fabric_port_acc_test.go +++ b/equinix/resource_fabric_port_acc_test.go @@ -17,7 +17,7 @@ func TestAccFabricReadPort(t *testing.T) { Config: testAccFabricReadPortConfig(), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr( - "data.equinix_fabric_port.test", "name", fmt.Sprint("ops-user100-CX-SV1-NL-Qinq-STD-1G-PRI-NK-349")), + "data.equinix_fabric_port.test", "name", "ops-user100-CX-SV1-NL-Qinq-STD-1G-PRI-NK-349"), ), }, }, @@ -25,9 +25,9 @@ func TestAccFabricReadPort(t *testing.T) { } func testAccFabricReadPortConfig() string { - return fmt.Sprint(`data "equinix_fabric_port" "test" { + return `data "equinix_fabric_port" "test" { uuid = "c4d9350e-783c-83cd-1ce0-306a5c00a600" - }`) + }` } // Get Ports By Name @@ -51,9 +51,9 @@ func TestAccFabricGetPortsByName(t *testing.T) { resource.TestCheckResourceAttr( "data.equinix_fabric_ports.test", "data.#", fmt.Sprint(1)), resource.TestCheckResourceAttr( - "data.equinix_fabric_ports.test", "data.0.name", fmt.Sprint("ops-user100-CX-DC11-NL-Dot1q-BO-10G-SEC-JP-113")), + "data.equinix_fabric_ports.test", "data.0.name", "ops-user100-CX-DC11-NL-Dot1q-BO-10G-SEC-JP-113"), resource.TestCheckResourceAttr( - "data.equinix_fabric_ports.test", "data.0.uuid", fmt.Sprint("c4d9350e-7791-791d-1ce0-306a5c00a600")), + "data.equinix_fabric_ports.test", "data.0.uuid", "c4d9350e-7791-791d-1ce0-306a5c00a600"), resource.TestCheckNoResourceAttr( "data.equinix_fabric_ports.test", "pagination"), ), diff --git a/equinix/resource_fabric_routing_protocol.go b/equinix/resource_fabric_routing_protocol.go index e2591759b..8cabf2ec9 100644 --- a/equinix/resource_fabric_routing_protocol.go +++ b/equinix/resource_fabric_routing_protocol.go @@ -191,6 +191,7 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Type: schema.TypeSet, Optional: true, Description: "Routing Protocol Direct IPv4", + MaxItems: 1, Elem: &schema.Resource{ Schema: createDirectConnectionIpv4Sch(), }, @@ -199,6 +200,7 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Type: schema.TypeSet, Optional: true, Description: "Routing Protocol Direct IPv6", + MaxItems: 1, Elem: &schema.Resource{ Schema: createDirectConnectionIpv6Sch(), }, @@ -207,6 +209,7 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Type: schema.TypeSet, Optional: true, Description: "Routing Protocol BGP IPv4", + MaxItems: 1, Elem: &schema.Resource{ Schema: createBgpConnectionIpv4Sch(), }, @@ -215,6 +218,7 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Type: schema.TypeSet, Optional: true, Description: "Routing Protocol BGP IPv6", + MaxItems: 1, Elem: &schema.Resource{ Schema: createBgpConnectionIpv6Sch(), }, @@ -238,6 +242,7 @@ func createFabricRoutingProtocolResourceSchema() map[string]*schema.Schema { Type: schema.TypeSet, Optional: true, Description: "Bidirectional Forwarding Detection", + MaxItems: 1, Elem: &schema.Resource{ Schema: createRoutingProtocolBfdSch(), }, @@ -621,7 +626,7 @@ func waitForRoutingProtocolUpdateCompletion(rpChangeUuid string, uuid string, co } func routingProtocolDirectIpv4TerraformToGo(routingProtocolDirectIpv4Request []interface{}) fabricv4.DirectConnectionIpv4 { - if routingProtocolDirectIpv4Request == nil || len(routingProtocolDirectIpv4Request) == 0 { + if len(routingProtocolDirectIpv4Request) == 0 { return fabricv4.DirectConnectionIpv4{} } @@ -637,7 +642,7 @@ func routingProtocolDirectIpv4TerraformToGo(routingProtocolDirectIpv4Request []i } func routingProtocolDirectIpv6TerraformToGo(routingProtocolDirectIpv6Request []interface{}) fabricv4.DirectConnectionIpv6 { - if routingProtocolDirectIpv6Request == nil || len(routingProtocolDirectIpv6Request) == 0 { + if len(routingProtocolDirectIpv6Request) == 0 { return fabricv4.DirectConnectionIpv6{} } rpDirectIpv6 := fabricv4.DirectConnectionIpv6{} @@ -651,7 +656,7 @@ func routingProtocolDirectIpv6TerraformToGo(routingProtocolDirectIpv6Request []i } func routingProtocolBgpIpv4TerraformToGo(routingProtocolBgpIpv4Request []interface{}) fabricv4.BGPConnectionIpv4 { - if routingProtocolBgpIpv4Request == nil || len(routingProtocolBgpIpv4Request) == 0 { + if len(routingProtocolBgpIpv4Request) == 0 { return fabricv4.BGPConnectionIpv4{} } @@ -668,7 +673,7 @@ func routingProtocolBgpIpv4TerraformToGo(routingProtocolBgpIpv4Request []interfa } func routingProtocolBgpIpv6TerraformToGo(routingProtocolBgpIpv6Request []interface{}) fabricv4.BGPConnectionIpv6 { - if routingProtocolBgpIpv6Request == nil || len(routingProtocolBgpIpv6Request) == 0 { + if len(routingProtocolBgpIpv6Request) == 0 { return fabricv4.BGPConnectionIpv6{} } @@ -685,7 +690,7 @@ func routingProtocolBgpIpv6TerraformToGo(routingProtocolBgpIpv6Request []interfa } func routingProtocolBfdTerraformToGo(routingProtocolBfdRequest []interface{}) fabricv4.RoutingProtocolBFD { - if routingProtocolBfdRequest == nil || len(routingProtocolBfdRequest) == 0 { + if len(routingProtocolBfdRequest) == 0 { return fabricv4.RoutingProtocolBFD{} } @@ -710,11 +715,10 @@ func routingProtocolDirectConnectionIpv4GoToTerraform(routingProtocolDirectIpv4 "equinix_iface_ip": routingProtocolDirectIpv4.GetEquinixIfaceIp(), } - rpDirectIpv4Set := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createDirectConnectionIpv4Sch()}), []interface{}{mappedDirectIpv4}, ) - return rpDirectIpv4Set } func routingProtocolDirectConnectionIpv6GoToTerraform(routingProtocolDirectIpv6 *fabricv4.DirectConnectionIpv6) *schema.Set { @@ -726,11 +730,10 @@ func routingProtocolDirectConnectionIpv6GoToTerraform(routingProtocolDirectIpv6 "equinix_iface_ip": routingProtocolDirectIpv6.GetEquinixIfaceIp(), } - rpDirectIpv6Set := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createDirectConnectionIpv6Sch()}), []interface{}{mappedDirectIpv6}, ) - return rpDirectIpv6Set } func routingProtocolBgpConnectionIpv4GoToTerraform(routingProtocolBgpIpv4 *fabricv4.BGPConnectionIpv4) *schema.Set { @@ -743,11 +746,10 @@ func routingProtocolBgpConnectionIpv4GoToTerraform(routingProtocolBgpIpv4 *fabri "equinix_peer_ip": routingProtocolBgpIpv4.GetEquinixPeerIp(), "enabled": routingProtocolBgpIpv4.GetEnabled(), } - rpBgpIpv4Set := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createBgpConnectionIpv4Sch()}), []interface{}{mappedBgpIpv4}, ) - return rpBgpIpv4Set } func routingProtocolBgpConnectionIpv6GoToTerraform(routingProtocolBgpIpv6 *fabricv4.BGPConnectionIpv6) *schema.Set { @@ -761,11 +763,10 @@ func routingProtocolBgpConnectionIpv6GoToTerraform(routingProtocolBgpIpv6 *fabri "enabled": routingProtocolBgpIpv6.GetEnabled(), } - rpBgpIpv6Set := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createBgpConnectionIpv6Sch()}), []interface{}{mappedBgpIpv6}, ) - return rpBgpIpv6Set } func routingProtocolBfdGoToTerraform(routingProtocolBfd *fabricv4.RoutingProtocolBFD) *schema.Set { @@ -778,11 +779,10 @@ func routingProtocolBfdGoToTerraform(routingProtocolBfd *fabricv4.RoutingProtoco "interval": routingProtocolBfd.GetInterval(), } - rpBfdSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createRoutingProtocolBfdSch()}), []interface{}{mappedRpBfd}, ) - return rpBfdSet } func routingProtocolOperationGoToTerraform(routingProtocolOperation *fabricv4.RoutingProtocolOperation) *schema.Set { @@ -795,11 +795,10 @@ func routingProtocolOperationGoToTerraform(routingProtocolOperation *fabricv4.Ro mappedRpOperation["errors"] = equinix_fabric_schema.ErrorGoToTerraform(errors) } - rpOperationSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createRoutingProtocolOperationSch()}), []interface{}{mappedRpOperation}, ) - return rpOperationSet } func routingProtocolChangeGoToTerraform(routingProtocolChange *fabricv4.RoutingProtocolChange) *schema.Set { @@ -813,9 +812,8 @@ func routingProtocolChangeGoToTerraform(routingProtocolChange *fabricv4.RoutingP "href": routingProtocolChange.GetHref(), } - rpChangeSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createRoutingProtocolChangeSch()}), []interface{}{mappedRpChange}, ) - return rpChangeSet } diff --git a/equinix/resource_fabric_service_profile.go b/equinix/resource_fabric_service_profile.go index 9e3eb3cec..19812ab9f 100644 --- a/equinix/resource_fabric_service_profile.go +++ b/equinix/resource_fabric_service_profile.go @@ -14,9 +14,9 @@ import ( equinix_errors "github.com/equinix/terraform-provider-equinix/internal/errors" equinix_fabric_schema "github.com/equinix/terraform-provider-equinix/internal/fabric/schema" equinix_schema "github.com/equinix/terraform-provider-equinix/internal/schema" + equinix_validation "github.com/equinix/terraform-provider-equinix/internal/validation" "github.com/equinix/terraform-provider-equinix/internal/config" - "github.com/hashicorp/terraform-plugin-sdk/v2/diag" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/retry" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" @@ -32,8 +32,8 @@ func fabricServiceProfileSchema() map[string]*schema.Schema { "type": { Type: schema.TypeString, Required: true, - ValidateFunc: validation.StringInSlice([]string{"L2_PROFILE", "L3_PROFILE", "ECIA_PROFILE", "ECMC_PROFILE", "IA_PROFILE"}, true), - Description: "Service profile type - L2_PROFILE, L3_PROFILE, ECIA_PROFILE, ECMC_PROFILE, IA_PROFILE", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedServiceProfileTypeEnumEnumValues, true), + Description: fmt.Sprintf("Service profile type. One of %v", fabricv4.AllowedServiceProfileTypeEnumEnumValues), }, "visibility": { Type: schema.TypeString, @@ -365,7 +365,8 @@ func createSPAccessPointTypeConfigSch() map[string]*schema.Schema { "type": { Type: schema.TypeString, Required: true, - Description: "Type of access point type config - VD, COLO", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedServiceProfileAccessPointTypeEnumEnumValues, false), + Description: fmt.Sprintf("Type of access point type config. One of %v", fabricv4.AllowedServiceProfileAccessPointTypeEnumEnumValues), }, "uuid": { Type: schema.TypeString, @@ -650,7 +651,7 @@ func resourceFabricServiceProfileUpdate(ctx context.Context, d *schema.ResourceD updateTimeout := d.Timeout(schema.TimeoutUpdate) - 30*time.Second - time.Since(start) var err error var eTag int64 = 0 - _, err, eTag = waitForActiveServiceProfileAndPopulateETag(uuid, meta, d, ctx, updateTimeout) + _, eTag, err = waitForActiveServiceProfileAndPopulateETag(uuid, meta, d, ctx, updateTimeout) if err != nil { if !strings.Contains(err.Error(), "500") { d.SetId("") @@ -702,7 +703,7 @@ func waitForServiceProfileUpdateCompletion(uuid string, meta interface{}, d *sch return dbSp, err } -func waitForActiveServiceProfileAndPopulateETag(uuid string, meta interface{}, d *schema.ResourceData, ctx context.Context, timeout time.Duration) (*fabricv4.ServiceProfile, error, int64) { +func waitForActiveServiceProfileAndPopulateETag(uuid string, meta interface{}, d *schema.ResourceData, ctx context.Context, timeout time.Duration) (*fabricv4.ServiceProfile, int64, error) { log.Printf("Waiting for service profile to be in active state, uuid %s", uuid) var eTag int64 = 0 stateConf := &retry.StateChangeConf{ @@ -735,7 +736,7 @@ func waitForActiveServiceProfileAndPopulateETag(uuid string, meta interface{}, d if err == nil { dbServiceProfile = inter.(*fabricv4.ServiceProfile) } - return dbServiceProfile, err, eTag + return dbServiceProfile, eTag, err } func resourceFabricServiceProfileDelete(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics { @@ -922,11 +923,11 @@ func marketingInfoGoToTerraform(mkinfo *fabricv4.MarketingInfo) *schema.Set { if processSteps != nil { mappedMkInfo["process_step"] = processSteps } - marketingInfoSet := schema.NewSet( + + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createMarketingInfoSch()}), []interface{}{mappedMkInfo}, ) - return marketingInfoSet } func serviceProfileAccessPointColoGoToTerraform(accessPointColos []fabricv4.ServiceProfileAccessPointCOLO) []interface{} { @@ -1077,10 +1078,9 @@ func apiConfigGoToTerraform(apiConfig *fabricv4.ApiConfig) *schema.Set { mappedApiConfig["integration_id"] = apiConfig.GetIntegrationId() mappedApiConfig["equinix_managed_port"] = apiConfig.GetEquinixManagedPort() - apiConfigSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createApiConfigSch()}), []interface{}{mappedApiConfig}) - return apiConfigSet } func authenticationKeyGoToTerraform(authenticationKey *fabricv4.AuthenticationKey) *schema.Set { @@ -1089,10 +1089,9 @@ func authenticationKeyGoToTerraform(authenticationKey *fabricv4.AuthenticationKe mappedAuthenticationKey["label"] = authenticationKey.GetLabel() mappedAuthenticationKey["description"] = authenticationKey.GetDescription() - apiConfigSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: createAuthenticationKeySch()}), []interface{}{mappedAuthenticationKey}) - return apiConfigSet } func supportedBandwidthsGoToTerraform(supportedBandwidths []int32) []interface{} { @@ -1103,6 +1102,7 @@ func supportedBandwidthsGoToTerraform(supportedBandwidths []int32) []interface{} for index, bandwidth := range supportedBandwidths { mappedSupportedBandwidths[index] = int(bandwidth) } + return mappedSupportedBandwidths } @@ -1234,7 +1234,7 @@ func portsTerraformToGo(schemaPorts []interface{}) []fabricv4.ServiceProfileAcce } locationList := portMap["location"].(*schema.Set).List() - if locationList != nil && len(locationList) != 0 { + if len(locationList) != 0 { pLocation := equinix_fabric_schema.LocationTerraformToGo(locationList) coloPort.SetLocation(pLocation) } @@ -1268,7 +1268,7 @@ func virtualDevicesTerraformToGo(schemaVirtualDevices []interface{}) []fabricv4. vdMap := virtualDevice.(map[string]interface{}) vType := fabricv4.ServiceProfileAccessPointVDType(vdMap["type"].(string)) vUuid := vdMap["uuid"].(string) - locationList := vdMap["location"].(interface{}).(*schema.Set).List() + locationList := vdMap["location"].(*schema.Set).List() var vLocation fabricv4.SimplifiedLocation if len(locationList) != 0 { vLocation = equinix_fabric_schema.LocationTerraformToGo(locationList) @@ -1288,23 +1288,20 @@ func metrosTerraformToGo(schemaMetros []interface{}) []fabricv4.ServiceMetro { if schemaMetros == nil { return nil } - var metros []fabricv4.ServiceMetro + metros := make([]fabricv4.ServiceMetro, len(schemaMetros)) for index, metro := range schemaMetros { metroMap := metro.(map[string]interface{}) - mCode := metroMap["code"].(string) - mName := metroMap["name"].(string) + ibxsRaw := metroMap["ibxs"].([]interface{}) mIbxs := converters.IfArrToStringArr(ibxsRaw) - mInTrail := metroMap["in_trail"].(bool) - mDisplayName := metroMap["display_name"].(string) - mSellerRegions := metroMap["seller_regions"].(map[string]string) + mappedMetro := fabricv4.ServiceMetro{} - mappedMetro.SetCode(mCode) - mappedMetro.SetName(mName) + mappedMetro.SetCode(metroMap["code"].(string)) + mappedMetro.SetName(metroMap["name"].(string)) mappedMetro.SetIbxs(mIbxs) - mappedMetro.SetInTrail(mInTrail) - mappedMetro.SetDisplayName(mDisplayName) - mappedMetro.SetSellerRegions(mSellerRegions) + mappedMetro.SetInTrail(metroMap["in_trail"].(bool)) + mappedMetro.SetDisplayName(metroMap["display_name"].(string)) + mappedMetro.SetSellerRegions(metroMap["seller_regions"].(map[string]string)) metros[index] = mappedMetro } return metros diff --git a/internal/fabric/schema/fabric_common_mapping_helpers.go b/internal/fabric/schema/fabric_common_mapping_helpers.go index 387248bd1..1755aacae 100644 --- a/internal/fabric/schema/fabric_common_mapping_helpers.go +++ b/internal/fabric/schema/fabric_common_mapping_helpers.go @@ -8,7 +8,7 @@ import ( ) func OrderTerraformToGo(orderTerraform []interface{}) fabricv4.Order { - if orderTerraform == nil || len(orderTerraform) == 0 { + if len(orderTerraform) == 0 { return fabricv4.Order{} } var order fabricv4.Order @@ -43,11 +43,11 @@ func OrderGoToTerraform(order *fabricv4.Order) *schema.Set { mappedOrder["billing_tier"] = order.GetBillingTier() mappedOrder["order_id"] = order.GetOrderId() mappedOrder["order_number"] = order.GetOrderNumber() - orderSet := schema.NewSet( + + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: OrderSch()}), []interface{}{mappedOrder}, ) - return orderSet } func AccountGoToTerraform[accountType *fabricv4.SimplifiedAccount | *fabricv4.SimplifiedAccountPortResponse](accountParam accountType) *schema.Set { @@ -85,16 +85,14 @@ func AccountGoToTerraform[accountType *fabricv4.SimplifiedAccount | *fabricv4.Si } } - accountSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: AccountSch()}), []interface{}{mappedAccount}, ) - - return accountSet } func NotificationsTerraformToGo(notificationsTerraform []interface{}) []fabricv4.SimplifiedNotification { - if notificationsTerraform == nil || len(notificationsTerraform) == 0 { + if len(notificationsTerraform) == 0 { return nil } notifications := make([]fabricv4.SimplifiedNotification, len(notificationsTerraform)) @@ -131,7 +129,7 @@ func NotificationsGoToTerraform(notifications []fabricv4.SimplifiedNotification) } func LocationTerraformToGo(locationList []interface{}) fabricv4.SimplifiedLocation { - if locationList == nil || len(locationList) == 0 { + if len(locationList) == 0 { return fabricv4.SimplifiedLocation{} } @@ -167,15 +165,14 @@ func LocationGoToTerraform(location *fabricv4.SimplifiedLocation) *schema.Set { mappedLocations["metro_code"] = location.GetMetroCode() mappedLocations["ibx"] = location.GetIbx() - locationSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: LocationSch()}), []interface{}{mappedLocations}, ) - return locationSet } func LocationWithoutIBXTerraformToGo(locationList []interface{}) fabricv4.SimplifiedLocationWithoutIBX { - if locationList == nil || len(locationList) == 0 { + if len(locationList) == 0 { return fabricv4.SimplifiedLocationWithoutIBX{} } @@ -193,15 +190,14 @@ func LocationWithoutIBXGoToTerraform(location *fabricv4.SimplifiedLocationWithou "metro_code": location.GetMetroCode(), } - locationSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: LocationSch()}), []interface{}{mappedLocation}, ) - return locationSet } func ProjectTerraformToGo(projectTerraform []interface{}) fabricv4.Project { - if projectTerraform == nil || len(projectTerraform) == 0 { + if len(projectTerraform) == 0 { return fabricv4.Project{} } var project fabricv4.Project @@ -245,15 +241,14 @@ func ChangeLogGoToTerraform(changeLog *fabricv4.Changelog) *schema.Set { "deleted_date_time": changeLog.GetDeletedDateTime().String(), } - changeLogSet := schema.NewSet( + return schema.NewSet( schema.HashResource(&schema.Resource{Schema: ChangeLogSch()}), []interface{}{mappedChangeLog}, ) - return changeLogSet } func ErrorGoToTerraform(errors []fabricv4.Error) []interface{} { - if errors == nil || len(errors) == 0 { + if len(errors) == 0 { return nil } mappedErrors := make([]interface{}, len(errors)) diff --git a/internal/fabric/schema/fabric_common_schemas.go b/internal/fabric/schema/fabric_common_schemas.go index 48cc31b91..6ad1f938e 100644 --- a/internal/fabric/schema/fabric_common_schemas.go +++ b/internal/fabric/schema/fabric_common_schemas.go @@ -1,33 +1,33 @@ package schema import ( + "fmt" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" + "github.com/equinix/equinix-sdk-go/services/fabricv4" + equinix_validation "github.com/equinix/terraform-provider-equinix/internal/validation" ) func OrderSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "purchase_order_number": { Type: schema.TypeString, - Computed: true, Optional: true, - Description: "Purchase order number", + Description: "Purchase order number. Short name/number to identify this order on the invoice", }, "billing_tier": { Type: schema.TypeString, Computed: true, - Optional: true, Description: "Billing tier for connection bandwidth", }, "order_id": { Type: schema.TypeString, Computed: true, - Optional: true, Description: "Order Identification", }, "order_number": { Type: schema.TypeString, Computed: true, - Optional: true, Description: "Order Reference Number", }, } @@ -38,7 +38,8 @@ func NotificationSch() map[string]*schema.Schema { "type": { Type: schema.TypeString, Required: true, - Description: "Notification Type - ALL,CONNECTION_APPROVAL,SALES_REP_NOTIFICATIONS, NOTIFICATIONS", + ValidateFunc: equinix_validation.StringInEnumSlice(fabricv4.AllowedSimplifiedNotificationTypeEnumValues, false), + Description: fmt.Sprintf("Notification type. One of %v", fabricv4.AllowedSimplifiedNotificationTypeEnumValues), }, "send_interval": { Type: schema.TypeString, @@ -130,19 +131,19 @@ func LocationSch() map[string]*schema.Schema { } } +func LocationSchWithoutIbx() map[string]*schema.Schema { + schemaMap := LocationSch() + delete(schemaMap, "ibx") + return schemaMap +} + func ProjectSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "project_id": { Type: schema.TypeString, - Computed: true, - Optional: true, + Required: true, Description: "Project Id", }, - "href": { - Type: schema.TypeString, - Computed: true, - Description: "Unique Resource URL", - }, } } @@ -211,6 +212,29 @@ func ChangeLogSch() map[string]*schema.Schema { } } +func OperationSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "provider_status": { + Type: schema.TypeString, + Computed: true, + Description: "Connection provider readiness status", + }, + "equinix_status": { + Type: schema.TypeString, + Computed: true, + Description: "Connection status", + }, + "errors": { + Type: schema.TypeList, + Computed: true, + Description: "Errors occurred", + Elem: &schema.Resource{ + Schema: ErrorSch(), + }, + }, + } +} + func ErrorSch() map[string]*schema.Schema { return map[string]*schema.Schema{ "error_code": { @@ -263,3 +287,51 @@ func ErrorAdditionalInfoSch() map[string]*schema.Schema { }, } } + +func PortSch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "uuid": { + Type: schema.TypeString, + Required: true, + Description: "Equinix-assigned Port identifier", + }, + "href": { + Type: schema.TypeString, + Computed: true, + Description: "Unique Resource Identifier", + }, + "name": { + Type: schema.TypeString, + Computed: true, + Description: "Port name", + }, + "redundancy": { + Type: schema.TypeSet, + Computed: true, + Description: "Redundancy Information", + Elem: &schema.Resource{ + Schema: PortRedundancySch(), + }, + }, + } +} + +func PortRedundancySch() map[string]*schema.Schema { + return map[string]*schema.Schema{ + "enabled": { + Type: schema.TypeBool, + Computed: true, + Description: "Access point redundancy", + }, + "group": { + Type: schema.TypeString, + Computed: true, + Description: "Port redundancy group", + }, + "priority": { + Type: schema.TypeString, + Computed: true, + Description: "Priority type - Primary or Secondary", + }, + } +} \ No newline at end of file diff --git a/internal/validation/strings.go b/internal/validation/strings.go index b112ecaaa..ded612177 100644 --- a/internal/validation/strings.go +++ b/internal/validation/strings.go @@ -1,7 +1,9 @@ package validation import ( + "fmt" "regexp" + "strings" "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation" @@ -16,3 +18,24 @@ var ( StringIsSpeedBand = validation.StringMatch(regexp.MustCompile("^[0-9]+(MB|GB)$"), "SpeedBand should consist of digit followed by MB or GB") StringIsCountryCode = stringvalidator.RegexMatches(regexp.MustCompile("(?i)^[a-z]{2}$"), "Address country must be a two letter code (ISO 3166-1 alpha-2)") ) + +// StringInEnumSlice checks if a string is in a slice of enum +func StringInEnumSlice[T ~string](valid []T, ignoreCase bool) func(i interface{}, k string) (warnings []string, errors []error) { + return func(i interface{}, k string) (warnings []string, errors []error) { + v, ok := i.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected type of %s to be string", k)) + return warnings, errors + } + + for _, item := range valid { + str := string(item) + if str == v || (ignoreCase && strings.EqualFold(v, str)) { + return warnings, errors + } + } + + errors = append(errors, fmt.Errorf("expected %s to be one of %q, got %s", k, valid, v)) + return warnings, errors + } +}