Skip to content

Commit 1b8b696

Browse files
authored
Merge pull request #10 from equinix-labs/metal_auto_approval
updated to use always fabric billed instead of deprecated shared ports feature
2 parents bff26d6 + 70b23d2 commit 1b8b696

File tree

10 files changed

+44
-208
lines changed

10 files changed

+44
-208
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@
77

88
A part of Platform Equinix, your Equinix Metal™ infrastructure can connect with other parties, such as public cloud providers, network service providers, or your own colocation cages in Equinix by defining an [Equinix Fabric - software-defined interconnections](https://metal.equinix.com/developers/docs/equinix-interconnect/introduction/)
99

10-
Setting Up a Shared Port requires requesting the connection on the Equinix Metal side, retrieving a token and using that token to request a connection on the Equinix Fabric side. This module is intended to abstract you from this process and handle the connection as a single resource.
10+
Setting Up a [Fabric Billed Fabric Virtual Connections](https://deploy.equinix.com/developers/docs/metal/interconnections/fabric-billed-fabric-vc/) requires requesting the connection on the Equinix Metal side, retrieving a token and using that token to request a connection on the Equinix Fabric side. This module is intended to abstract you from this process and handle the connection as a single resource.
1111

1212
```html
13-
Origin Destination
13+
Origin Destination
1414
(A-side) (Z-side)
1515

16-
┌────────────────┐ ┌───────────────┐
17-
│ Equinix Fabric │ Equinix Metal │ Equinix Metal │
18-
│ Port / Network ├───── Shared connection ───────►│ Shared Port │
19-
│ Edge Device / │ (50 Mbps - 10 Gbps) └───────────────┘
20-
│ Service Token │
16+
┌────────────────┐ ┌───────────────┐
17+
│ Equinix Fabric │ Equinix Metal │ Equinix Metal │
18+
│ Port / Network ├───── Fabric Billed ───────►│ Port
19+
│ Edge Device / │ Virtual Connection └───────────────┘
20+
│ Service Token │ (50 Mbps - 10 Gbps)
2121
└────────────────┘
2222
```
2323

@@ -74,6 +74,5 @@ See <https://registry.terraform.io/modules/equinix-labs/fabric-connection-metal/
7474
### Examples
7575

7676
- [Fabric Port connection](https://registry.terraform.io/modules/equinix-labs/fabric-connection-metal/equinix/latest/examples/fabric-port-connection/)
77-
- [Fabric Port connection wiht Metal z-side service token](https://registry.terraform.io/modules/equinix-labs/fabric-connection-metal/equinix/latest/examples/fabric-port-connection-with-zside-token/)
7877
- [Network Edge device redundant connection](https://registry.terraform.io/modules/equinix-labs/fabric-connection-metal/equinix/latest/examples/network-edge-device-redundant-connection/)
7978
- [Fabric a-side Service Token redundant connection](https://registry.terraform.io/modules/equinix-labs/fabric-connection-metal/equinix/latest/examples/service-token-redundant-connection)

examples/fabric-port-connection-with-zside-token/README.md

Lines changed: 0 additions & 34 deletions
This file was deleted.

examples/fabric-port-connection-with-zside-token/main.tf

Lines changed: 0 additions & 50 deletions
This file was deleted.

examples/fabric-port-connection-with-zside-token/outputs.tf

Lines changed: 0 additions & 3 deletions
This file was deleted.

examples/fabric-port-connection-with-zside-token/variables.tf

Lines changed: 0 additions & 30 deletions
This file was deleted.

examples/fabric-port-connection-with-zside-token/versions.tf

Lines changed: 0 additions & 10 deletions
This file was deleted.

examples/network-edge-device-redundant-connection/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ module "equinix-fabric-connection-metal" {
99
# required variables
1010
fabric_notification_users = ["example@equinix.com"]
1111
fabric_destination_metro_code = "DA" // corresponds to Dallas
12-
13-
metal_project_name = var.metal_project_name
12+
metal_project_name = var.metal_project_name
1413

1514
# optional variables
1615
redundancy_type = "REDUNDANT"

main.tf

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
locals {
22
metal_connection_name = coalesce(var.metal_connection_name, lower(format("shared-conn-%s-%s", var.fabric_destination_metro_code, random_string.this.result)))
33
fabric_primary_name = var.fabric_connection_name != "" ? var.fabric_connection_name : upper(format("METAL-%s-%s", var.fabric_destination_metro_code, random_string.this.result))
4+
fabric_secondary_name = var.fabric_secondary_connection_name != "" ? var.fabric_secondary_connection_name : format("%s-SEC", local.fabric_primary_name)
5+
network_edge_secondary_device_id = var.network_edge_secondary_device_id != "" ? var.network_edge_secondary_device_id : var.network_edge_device_id
46
}
57

68
data "equinix_metal_project" "this" {
@@ -23,58 +25,29 @@ resource "equinix_metal_connection" "this" {
2325
tags = var.metal_connection_tags
2426
speed = format("%dMbps", var.fabric_speed)
2527
vlans = var.metal_connection_vlans
26-
service_token_type = var.service_token_automation_feature_preview ? "z_side" : null
28+
service_token_type = "z_side"
2729
}
2830

2931
module "equinix-fabric-connection" {
32+
count = var.redundancy_type == "REDUNDANT" ? 2 : 1
3033
source = "equinix-labs/fabric-connection/equinix"
31-
version = "0.3.1"
34+
version = "0.4.0"
3235

3336
# required variables
3437
notification_users = var.fabric_notification_users
3538

3639
# optional variables
37-
name = local.fabric_primary_name
38-
network_edge_id = var.network_edge_device_id
39-
network_edge_interface_id = var.network_edge_device_interface_id
40-
port_name = var.fabric_port_name
41-
vlan_stag = var.fabric_vlan_stag
42-
service_token_id = var.fabric_service_token_id
43-
speed = var.fabric_speed
44-
speed_unit = "MB"
45-
purchase_order_number = var.fabric_purchase_order_number
46-
47-
zside_service_token_id = var.service_token_automation_feature_preview ? equinix_metal_connection.this.service_tokens.0.id : null
48-
seller_profile_name = var.service_token_automation_feature_preview ? "" : var.redundancy_type == "SINGLE" ? "Equinix Metal - Layer 2" : "Equinix Metal - Layer 2 - Redundant"
49-
seller_authorization_key = var.service_token_automation_feature_preview ? "" : equinix_metal_connection.this.token
50-
seller_metro_code = var.service_token_automation_feature_preview ? "" : var.fabric_destination_metro_code
51-
52-
redundancy_type = var.service_token_automation_feature_preview ? "SINGLE" : var.redundancy_type
53-
secondary_name = var.service_token_automation_feature_preview ? "" : var.fabric_secondary_connection_name
54-
secondary_port_name = var.service_token_automation_feature_preview ? "" : var.fabric_secondary_port_name
55-
secondary_vlan_stag = var.service_token_automation_feature_preview ? 0 : var.fabric_secondary_vlan_stag
56-
secondary_service_token_id = var.service_token_automation_feature_preview ? "" : var.fabric_secondary_service_token_id
57-
network_edge_secondary_id = var.service_token_automation_feature_preview ? "" : var.network_edge_secondary_device_id
58-
network_edge_secondary_interface_id = var.service_token_automation_feature_preview ? 0 : var.network_edge_secondary_device_interface_id
59-
}
40+
name = count.index == 0 ? local.fabric_primary_name : local.fabric_secondary_name
6041

61-
module "equinix-fabric-connection-sec" {
62-
count = var.service_token_automation_feature_preview && var.redundancy_type == "REDUNDANT" ? 1 : 0
63-
source = "equinix-labs/fabric-connection/equinix"
64-
version = "0.4.0"
42+
network_edge_id = count.index == 0 ? var.network_edge_device_id : local.network_edge_secondary_device_id
43+
network_edge_interface_id = count.index == 0 ? var.network_edge_device_interface_id : var.network_edge_secondary_device_interface_id
6544

66-
# required variables
67-
notification_users = var.fabric_notification_users
68-
69-
# optional variables
70-
name = var.fabric_secondary_connection_name != "" ? var.fabric_secondary_connection_name : format("%s-SEC", local.fabric_primary_name)
71-
port_name = var.fabric_secondary_port_name != "" ? var.fabric_secondary_port_name : var.fabric_port_name
72-
vlan_stag = var.fabric_secondary_vlan_stag
73-
speed = var.fabric_speed
45+
port_name = count.index == 0 ? var.fabric_port_name : var.fabric_secondary_port_name != "" ? var.fabric_secondary_port_name : var.fabric_port_name
46+
vlan_stag = count.index == 0 ? var.fabric_vlan_stag : var.fabric_secondary_vlan_stag
47+
service_token_id = count.index == 0 ? var.fabric_service_token_id : var.fabric_secondary_service_token_id
48+
speed = count.index == 0 ? var.fabric_speed : var.fabric_secondary_speed != 0 ? var.fabric_secondary_speed : var.fabric_speed
7449
speed_unit = "MB"
7550
purchase_order_number = var.fabric_purchase_order_number
7651

77-
zside_service_token_id = equinix_metal_connection.this.service_tokens.1.id
78-
79-
redundancy_type = "SINGLE"
52+
zside_service_token_id = equinix_metal_connection.this.service_tokens[count.index].id
8053
}

outputs.tf

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,51 @@
11
output "fabric_connection_primary_uuid" {
22
description = "Unique identifier of the connection."
3-
value = module.equinix-fabric-connection.primary_connection.uuid
3+
value = module.equinix-fabric-connection.0.primary_connection.uuid
44
}
55

66
output "fabric_connection_primary_name" {
77
description = "Name of the connection."
8-
value = module.equinix-fabric-connection.primary_connection.name
8+
value = module.equinix-fabric-connection.0.primary_connection.name
99
}
1010

1111
output "fabric_connection_primary_status" {
1212
description = "Connection provisioning status."
13-
value = module.equinix-fabric-connection.primary_connection.status
13+
value = module.equinix-fabric-connection.0.primary_connection.status
1414
}
1515

1616
output "fabric_connection_primary_provider_status" {
1717
description = "Connection provisioning provider status."
18-
value = module.equinix-fabric-connection.primary_connection.provider_status
18+
value = module.equinix-fabric-connection.0.primary_connection.provider_status
1919
}
2020

2121
output "fabric_connection_primary_speed" {
2222
description = "Connection speed."
23-
value = module.equinix-fabric-connection.primary_connection.speed
23+
value = module.equinix-fabric-connection.0.primary_connection.speed
2424
}
2525

2626
output "fabric_connection_primary_speed_unit" {
2727
description = "Connection speed unit."
28-
value = module.equinix-fabric-connection.primary_connection.speed_unit
29-
}
30-
31-
output "fabric_connection_primary_seller_metro" {
32-
description = "Connection seller metro code."
33-
value = module.equinix-fabric-connection.primary_connection.seller_metro_code
28+
value = module.equinix-fabric-connection.0.primary_connection.speed_unit
3429
}
3530

3631
output "fabric_connection_secondary_uuid" {
3732
description = "Unique identifier of the secondary connection."
38-
value = module.equinix-fabric-connection.secondary_connection != null ? module.equinix-fabric-connection.secondary_connection.uuid : (
39-
var.service_token_automation_feature_preview && var.redundancy_type == "REDUNDANT") ? module.equinix-fabric-connection-sec.primary_connection.uuid : null
33+
value = var.redundancy_type == "REDUNDANT" ? module.equinix-fabric-connection.1.primary_connection.uuid : null
4034
}
4135

4236
output "fabric_connection_secondary_name" {
4337
description = "Name of the secondary connection."
44-
value = module.equinix-fabric-connection.secondary_connection != null ? module.equinix-fabric-connection.secondary_connection.name : (
45-
var.service_token_automation_feature_preview && var.redundancy_type == "REDUNDANT") ? module.equinix-fabric-connection-sec.primary_connection.name : null
38+
value = var.redundancy_type == "REDUNDANT" ? module.equinix-fabric-connection.1.primary_connection.name : null
4639
}
4740

4841
output "fabric_connection_secondary_status" {
4942
description = "Secondary connection provisioning status."
50-
value = module.equinix-fabric-connection.secondary_connection != null ? module.equinix-fabric-connection.secondary_connection.status : (
51-
var.service_token_automation_feature_preview && var.redundancy_type == "REDUNDANT") ? module.equinix-fabric-connection-sec.primary_connection.status : null
43+
value = var.redundancy_type == "REDUNDANT" ? module.equinix-fabric-connection.1.primary_connection.status : null
5244
}
5345

5446
output "fabric_connection_secondary_provider_status" {
5547
description = "Secondary connection provisioning provider status."
56-
value = module.equinix-fabric-connection.secondary_connection != null ? module.equinix-fabric-connection.secondary_connection.provider_status : (
57-
var.service_token_automation_feature_preview && var.redundancy_type == "REDUNDANT") ? module.equinix-fabric-connection-sec.primary_connection.provider_status : null
48+
value = var.redundancy_type == "REDUNDANT" ? module.equinix-fabric-connection.1.primary_connection.provider_status : null
5849
}
5950

6051
output "equinix_metal_connection_uuid" {

variables.tf

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ variable "fabric_connection_name" {
1616

1717
variable "fabric_destination_metro_code" {
1818
type = string
19-
description = "Destination Metro code where the connection will be created."
19+
description = "Destination Metal Metro code where the connection will be created."
2020

2121
validation {
2222
condition = can(regex("^[A-Z]{2}$", var.fabric_destination_metro_code))
@@ -79,6 +79,18 @@ variable "fabric_speed" {
7979
}
8080
}
8181

82+
variable "fabric_secondary_speed" {
83+
type = number
84+
description = <<EOF
85+
Speed/Bandwidth in Mbps to be allocated to the connection. If unspecified, it will be used the primary connection fabric speed.
86+
EOF
87+
default = 0
88+
validation {
89+
condition = contains([0, 50, 100, 200, 500, 1000, 2000, 5000, 10000], var.fabric_secondary_speed)
90+
error_message = "Valid values are (0, 50, 100, 200, 500, 1000, 2000, 5000, 10000)."
91+
}
92+
}
93+
8294
variable "fabric_purchase_order_number" {
8395
type = string
8496
description = "Connection's purchase order number to reflect on the invoice."
@@ -194,14 +206,3 @@ variable "metal_connection_vlans" {
194206
error_message = "Max. number of vlans is two (one per connection, primary and secondary)"
195207
}
196208
}
197-
198-
variable "service_token_automation_feature_preview" {
199-
type = bool
200-
description = <<EOF
201-
If true it will use automated service token type z_side. NOTE: Equinix Metal connection with service_token_type
202-
z_side/a_side is not generally available and may not be enabled yet for your organization. This new feature will
203-
provision the connection automatically after creation, but it is not compatible (July, 2022) with
204-
'fabric_service_token_id' or 'network_edge_device_id'.
205-
EOF
206-
default = false
207-
}

0 commit comments

Comments
 (0)